View Full Version : MYSQL OR Query
Weirfire
Jun 7th 2005, 6:08 am
I'm wanting to do something like
mysql_query("SELECT * FROM Table WHERE value='true' OR value2='true' OR value3='true'");
but I'm not sure what the correct syntax should be for the 'OR'. I've tried using the exact word OR but it doesnt seem to like it.
Any ideas?
sadcox66
Jun 7th 2005, 6:15 am
I'm wanting to do something like
mysql_query("SELECT * FROM Table WHERE value='true' OR value2='true' OR value3='true'");
but I'm not sure what the correct syntax should be for the 'OR'. I've tried using the exact word OR but it doesnt seem to like it.
Any ideas?
What error are you getting ? Make sure value1..n are declared boolean in db
Try
mysql_query("SELECT * FROM Table WHERE (value='true') OR (value2='true') OR (value3='true') ");
If you have phpMyAdmin - Use it's query builder to build the query for you.
Weirfire
Jun 7th 2005, 6:25 am
What error are you getting ? Make sure value1..n are declared boolean in db
Try
mysql_query("SELECT * FROM Table WHERE (value='true') OR (value2='true') OR (value3='true') ");
If you have phpMyAdmin - Use it's query builder to build the query for you.
Thanks sadcox,
I've been coding it in PHP for the mysql database and I do have phpmyAdmin so I'll check that out and see if I can get it to work there.
Is OR definitely the word to use for doing ORs?
Weirfire
Jun 7th 2005, 6:37 am
Looks like it could be some other syntax error that I've made because my query that I had worked properly.
Thanks for your help though sadcox. :)
sadcox66
Jun 9th 2005, 4:29 am
Good luck with it. If you post the error message I may be able to give more information.
I am guessing at this point the error message is probably from PHP.
+By the way most server administrators (cPanel/Plesk) already have phpMyAdmin already installed if you need to debug further.
Weirfire
Jun 9th 2005, 4:56 am
It was a human error that I made for the OR not to work. I had actually written the right query but forgot to display the results correctly for the query I had scripted.
Sometimes it just takes a wee while to notice the errors though :)
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.