erme Posted December 15, 2009 Share Posted December 15, 2009 Hi, Im trying to select more then one field in a table for a search function. select * from TABLENAME where FIELDNAME1 FIELDNAME2 '%".$_GET['content']."%' Quote Link to comment https://forums.phpfreaks.com/topic/185236-selecting-multiple-fields-from-a-table/ Share on other sites More sharing options...
Lamez Posted December 15, 2009 Share Posted December 15, 2009 SELECT * FROM $table WHERE col = 'val' Quote Link to comment https://forums.phpfreaks.com/topic/185236-selecting-multiple-fields-from-a-table/#findComment-977843 Share on other sites More sharing options...
erme Posted December 15, 2009 Author Share Posted December 15, 2009 SELECT * FROM $table WHERE col = 'val' So will this work? select * from TABLENAME where col = 'FIELDNAME1 FIELDNAME2' '%".$_GET['content']."%' Quote Link to comment https://forums.phpfreaks.com/topic/185236-selecting-multiple-fields-from-a-table/#findComment-977844 Share on other sites More sharing options...
Lamez Posted December 15, 2009 Share Posted December 15, 2009 no you need a and clause. SELECT * FROM $table WHERE col = 'val' AND col2 = 'val2' I think that is right. Quote Link to comment https://forums.phpfreaks.com/topic/185236-selecting-multiple-fields-from-a-table/#findComment-977851 Share on other sites More sharing options...
erme Posted December 15, 2009 Author Share Posted December 15, 2009 Got it to work thanks Quote Link to comment https://forums.phpfreaks.com/topic/185236-selecting-multiple-fields-from-a-table/#findComment-977872 Share on other sites More sharing options...
Lamez Posted December 15, 2009 Share Posted December 15, 2009 Hoped I helped. Mark as solved! Quote Link to comment https://forums.phpfreaks.com/topic/185236-selecting-multiple-fields-from-a-table/#findComment-977875 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.