Jaswinder Posted September 16, 2013 Share Posted September 16, 2013 hello friends.. i have one issue in searching.. my table structure is this column name type id int jokeby varchar joketitle varchar joke longtext when i run a sql command in my phpmyadmin select * from jokes where jokeby or joketitle like '%anonymous%' - it does not show result but when i change the order of columns like this select * from jokes where joketitle or jokeby like '%anonymous%' - it shows the result.. whats the mess ?? is there any particular order for this ?? i have 1 entry in the table with jokeby anonymous. Quote Link to comment https://forums.phpfreaks.com/topic/282180-searching-problem-in-mysql/ Share on other sites More sharing options...
Solution Barand Posted September 16, 2013 Solution Share Posted September 16, 2013 Correct syntax is select * from jokes where jokeby like '%anonymous%' or joketitle like '%anonymous%' Quote Link to comment https://forums.phpfreaks.com/topic/282180-searching-problem-in-mysql/#findComment-1449651 Share on other sites More sharing options...
vinny42 Posted September 16, 2013 Share Posted September 16, 2013 OR and AND always come between two expressions that give a boolean result, so "WHERE jokeby OR joketitle LIKE '%foo%'" tries to find records were jokeby equals TRUE, or joketitle contains 'foo'. SQL looks like English but it's not quite English ;-) Quote Link to comment https://forums.phpfreaks.com/topic/282180-searching-problem-in-mysql/#findComment-1449656 Share on other sites More sharing options...
Jaswinder Posted September 16, 2013 Author Share Posted September 16, 2013 thanks for such a knowledgeable reply Quote Link to comment https://forums.phpfreaks.com/topic/282180-searching-problem-in-mysql/#findComment-1449717 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.