MySQL Forums
Forum List  »  Newbie

Select multiple tables
Posted by: Dung Trinh
Date: August 22, 2005 01:46AM

Hi,
I have 2 tables that are very similar. Each table has the field 'house_num'. I want to query from those 2 tables all rows that house_num=165 and below is my query

Select * from table1 As A, table2 As B where A.house_num='165' AND B.house_num='165';

What I've got is 5 rows from table1 and 1 row from table2, that's correct but the problem is that they are not listed sequentially, instead they are combined together as for each row of table1 there's 1 row of table 2 followed right after as:

ROW1TABLE1+ROW1TABLE2
ROW2TABLE1+ROW1TABLE2
ROW3TABLE1+ROW1TABLE2
ROW4TABLE1+ROW1TABLE2
ROW5TABLE1+ROW1TABLE2

What I want to see should be

ROW1TABLE1
ROW2TABLE1
ROW3TABLE1
ROW4TABLE1
ROW5TABLE1
ROW1TABLE2

I cannot use UNION because my MYSQL version is 3.29 I cannot update it now. I'm really appreciated for any help. Thanks

Options: ReplyQuote


Subject
Written By
Posted
Select multiple tables
August 22, 2005 01:46AM
August 22, 2005 02:01AM
August 22, 2005 10:34AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.