Thanks for replay ! It works ! Other problem is to take two columns where each column is filled when it match (i.e. 40) and NULL when it doesn`t match:
tab1: id | test1 ------------ 0 | string1 1 | string2 2 | string3 and tab2: id | test1 ------------ 5 | string1 6 | string2 7 | string3 I query about id=0. And I`m looking for answer such: 0,NULL about id=6: NULL, 6 Do you have any idea ?? Best regards - Paul ----- Original Message ----- From: <[EMAIL PROTECTED]> To: "Paweł Filutowski" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Thursday, November 06, 2003 1:43 PM Subject: Re: How to get two columns from different tables You're almost there in how you worded your quesiton. You'll need a join. select tab1.test1, tab2.test1 from tab1 inner join tab2 on tab1.id = tab2.id. --> this will get all columns where hte ids match. to get all ids that are 40, add a where clause. select tab1.test1, tab2.test1 from tab1 inner join tab2 on tab1.id = tab2.id where tab1.id = 40. you may also want to look at other types of joins for other results. http://www.mysql.com/doc/en/JOIN.html hth Jeff Paweł Filutowski <[EMAIL PROTECTED] To: <[EMAIL PROTECTED]> rfam.pl> cc: Subject: How to get two columns from different tables 11/06/2003 07:32 AM Hello, I`m a newer reader. I have problem with query. There are two tables: tab1: id | test1 ------------ 0 | string1 1 | string2 2 | string3 and tab2: id | test1 ------------ 0 | string1 1 | string2 2 | string3 I want to get columns test1 (from tab1) and test2 where id.tab1 = id.tab2 but i don`t know how compare this expresion to constant i.e. id.tab1 = id.tab2 = 40 Haw Can I do this ? Regards -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]