Apr-16-2017, 08:13 AM
Im playing around with the old old forum database and realize that i am pretty bad at mysql commands. In this last command i am trying to extract all needles in a haystack of the keyword
metulburr
. metulburr@ubuntu:~$ sudo mysql -p [sudo] password for metulburr: Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 7 Server version: 5.7.17-0ubuntu0.16.04.2 (Ubuntu) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | py_forum | | sys | +--------------------+ 5 rows in set (0.00 sec) mysql> use py_forum; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> show tables; +----------------------------+ | Tables_in_py_forum | +----------------------------+ | phpbb_acl_groups | | phpbb_acl_options | | phpbb_acl_roles | | phpbb_acl_roles_data | | phpbb_acl_users | | phpbb_ad | | phpbb_attachments | | phpbb_banlist | | phpbb_bbcodes | | phpbb_bookmarks | | phpbb_bots | | phpbb_config | | phpbb_confirm | | phpbb_disallow | | phpbb_drafts | | phpbb_extension_groups | | phpbb_extensions | | phpbb_forums | | phpbb_forums_access | | phpbb_forums_track | | phpbb_forums_watch | | phpbb_groups | | phpbb_icons | | phpbb_lang | | phpbb_log | | phpbb_login_attempts | | phpbb_moderator_cache | | phpbb_modules | | phpbb_poll_options | | phpbb_poll_votes | | phpbb_posts | | phpbb_privmsgs | | phpbb_privmsgs_folder | | phpbb_privmsgs_rules | | phpbb_privmsgs_to | | phpbb_profile_fields | | phpbb_profile_fields_data | | phpbb_profile_fields_lang | | phpbb_profile_lang | | phpbb_ranks | | phpbb_reports | | phpbb_reports_reasons | | phpbb_search_results | | phpbb_search_wordlist | | phpbb_search_wordmatch | | phpbb_sessions | | phpbb_sessions_keys | | phpbb_sitelist | | phpbb_smilies | | phpbb_styles | | phpbb_styles_imageset | | phpbb_styles_imageset_data | | phpbb_styles_template | | phpbb_styles_template_data | | phpbb_styles_theme | | phpbb_topics | | phpbb_topics_posted | | phpbb_topics_track | | phpbb_topics_watch | | phpbb_user_group | | phpbb_users | | phpbb_warnings | | phpbb_words | | phpbb_zebra | +----------------------------+ 64 rows in set (0.00 sec) mysql> show columns from phpbb_posts; +------------------+-----------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------------+-----------------------+------+-----+---------+----------------+ | post_id | mediumint(8) unsigned | NO | PRI | NULL | auto_increment | | topic_id | mediumint(8) unsigned | NO | MUL | 0 | | | forum_id | mediumint(8) unsigned | NO | MUL | 0 | | | poster_id | mediumint(8) unsigned | NO | MUL | 0 | | | icon_id | mediumint(8) unsigned | NO | | 0 | | | poster_ip | varchar(40) | NO | MUL | | | | post_time | int(11) unsigned | NO | | 0 | | | post_approved | tinyint(1) unsigned | NO | MUL | 1 | | | post_reported | tinyint(1) unsigned | NO | | 0 | | | enable_bbcode | tinyint(1) unsigned | NO | | 1 | | | enable_smilies | tinyint(1) unsigned | NO | | 1 | | | enable_magic_url | tinyint(1) unsigned | NO | | 1 | | | enable_sig | tinyint(1) unsigned | NO | | 1 | | | post_username | varchar(255) | NO | MUL | | | | post_subject | varchar(255) | NO | MUL | | | | post_text | mediumtext | NO | MUL | NULL | | | post_checksum | varchar(32) | NO | | | | | post_attachment | tinyint(1) unsigned | NO | | 0 | | | bbcode_bitfield | varchar(255) | NO | | | | | bbcode_uid | varchar(8) | NO | | | | | post_postcount | tinyint(1) unsigned | NO | | 1 | | | post_edit_time | int(11) unsigned | NO | | 0 | | | post_edit_reason | varchar(255) | NO | | | | | post_edit_user | mediumint(8) unsigned | NO | | 0 | | | post_edit_count | smallint(4) unsigned | NO | | 0 | | | post_edit_locked | tinyint(1) unsigned | NO | | 0 | | +------------------+-----------------------+------+-----+---------+----------------+ 26 rows in set (0.00 sec) mysql> SELECT phpbb_posts WHERE post_text LIKE '%$metulburr%'; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE post_text LIKE '%$metulburr%'' at line 1 mysql>but i am getting a syntax error
Error:mysql> SELECT phpbb_posts WHERE post_text LIKE '%$metulburr%';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE post_text LIKE '%$metulburr%'' at line 1
Recommended Tutorials: