First, you need to perform a JOIN on the two tables, otherwise you will get all combinations of rows from the two tables. But that is not what you are asking about.
Using SELECT * is considered a bad programming practice. Always specify the select list (the columns you want to see/need to work on) unless you are simply selecting data in an ad hoc query to review the data in a row or a few rows. Once you specify what columns to select, you can use column aliases, which allows you to give columns that have the same name in the two tables different names. In the query, prefix the column names by the table name - or better - a table alias. For example: SELECT D.ID, D.Name as DeptName, D.Manager as DeptManager, E.ID as EmpID, E.DeptID, E.Name as EmpName, E.HiringDate as EmpHireDate FROM departments as D INNER JOIN employees as E ON E.DeptID = D.ID WHERE D.CompanyID = 36 HTH, Tore. ----- Original Message ----- From: "Frank de Bot" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, February 24, 2003 5:33 PM Subject: Select from multiple tables > Hi, > > I got the following query: > > SELECT * FROM t1,t2 > > In the result I get as column just the column name only, but I like to > get the table name with it, just I must use it in the where clause. How > can I do this? > > Thanks in advanced, > > Frank de Bot > > > > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php