TobesC Posted June 4, 2007 Share Posted June 4, 2007 i want to search multiple tables to see whether a certain user has posted more than three times in any category in my database. how can i do a search for the same field in different tables? thanks. Link to comment https://forums.phpfreaks.com/topic/54165-multiple-table-search-with-mysql/ Share on other sites More sharing options...
immanuelx2 Posted June 4, 2007 Share Posted June 4, 2007 easy, you use the 'as' function... here's an example: mysql_query = ("SELECT M.name, M.posts, C.name as category_name FROM members as M, categories as C WHERE M.category_id = C.id"); Link to comment https://forums.phpfreaks.com/topic/54165-multiple-table-search-with-mysql/#findComment-267779 Share on other sites More sharing options...
micah1701 Posted June 4, 2007 Share Posted June 4, 2007 select table1.columnName, table2.columnName FROM table1,table2 WHERE table1.columnName = '$value' OR table2.columnName = '$value' Link to comment https://forums.phpfreaks.com/topic/54165-multiple-table-search-with-mysql/#findComment-267781 Share on other sites More sharing options...
Renlok Posted June 4, 2007 Share Posted June 4, 2007 use sql join itd be something like SELECT * FROM table1, table2 WHERE table1.column = table2.column Or you could have SELECT * FROM table1 LEFT JOIN table2 ON ( table1.column = table2.column ) Link to comment https://forums.phpfreaks.com/topic/54165-multiple-table-search-with-mysql/#findComment-267783 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.