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
but i am getting a syntax error
metulburr
. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
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> |
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: