Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- select records from two tables
February 8, 2012, 7:06 pm
rate this thread
Re: select records from two tables
What are you trying to accomplish?
You are joining two tables with no relationship between the pairs
of records specified in an ON or WHERE clause. This is often (not
always, but often) a mistake.
This query selects every PAIR of records where one of the pair has
user = 'test'. Assuming that there is at least one user where user
= 'test' in both tables, this will include all records from either
of the tables as the first or second of the pair. If there are more
than one record with user = 'test' in each table, you'll get multiple
copies of each record.
If you want only pairs of records where both records have user =
'test', use AND not OR in the WHERE clause.
What is it you are attempting to do correctly?
What comes to mind is using two queries, one for each table. If
the two tables have the same structure, perhaps you want to use two
queries with UNION.
- » Americanas.com SALDO de TVs Com at 80% de Desconto (29798)
- — Newest thread in » MySQL Database Forum