Is there anything wrong with this query? I tried it on my PHPMyAdmin and my own php files and it takes forever and never returns any results. SELECT table1.*,table2.* FROM table1,table2 WHERE table1.field1='something' OR table2.field1='something' PHP: If I remove the OR part everything goes well but when I have that OR there it doesn't work. .
If you are using two tables, you should also put a join condition based on the common field, e.g. SELECT table1.*,table2.* FROM table1,table2 WHERE (table1.field1='something' OR table2.field1='something') and table1.commonid = table2.commonid PHP: Also check that you have an index on these fields.
But there is no commonid on tables and even if there was they wouldn't be the same because "something" is either on table1 or table2.
If there is no join field, perhaps you should then use a UNION: SELECT table1.field1 WHERE table1.field1='something' UNION SELECT table2.field1 WHERE table2.field1='something' PHP:
to make things easier if those tables don't have common link, then create separate select statements.