JSHINER Posted March 30, 2008 Share Posted March 30, 2008 SELECT table_1.*, table_2." FROM table_1, table_2 WHERE table_1.type = 1 OR table_1.type = 2 AND var = '$var' When I run the above with just type = 1 or type = 2 it works fine, but does not work together. What am I doing wrong? Link to comment https://forums.phpfreaks.com/topic/98697-question-about-a-query/ Share on other sites More sharing options...
BlueSkyIS Posted March 30, 2008 Share Posted March 30, 2008 for one, table_2." should be table_2.* you're also not identifying a relationship between the 2 tables, for instance WHERE table_1.id = table_2.rec_id Link to comment https://forums.phpfreaks.com/topic/98697-question-about-a-query/#findComment-505099 Share on other sites More sharing options...
JSHINER Posted March 30, 2008 Author Share Posted March 30, 2008 Sorry those were just examples. The real issue I have is the OR. I need it to pull records that are type = 1 OR type = 2 Link to comment https://forums.phpfreaks.com/topic/98697-question-about-a-query/#findComment-505124 Share on other sites More sharing options...
Barand Posted March 30, 2008 Share Posted March 30, 2008 use (..) to clarify whether it is WHERE (table_1.type = 1 OR table_1.type = 2) AND var = '$var' or WHERE table_1.type = 1 OR (table_1.type = 2 AND var = '$var') Link to comment https://forums.phpfreaks.com/topic/98697-question-about-a-query/#findComment-505184 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.