简体   繁体   中英

How to select two columns with a single WHERE clause?

How can I select more than one table in sql server while using a single where clause condition for both tables? For example, if I had two tables named table1 , table2 , then:

select * from table1,table2 where rollno=1

But in the above query it gives me error -

ambiguous column

which is logical.

提供Alias name或使用tablename以避免ambiguous column error并尝试。

select * from table1 A,table2 B where A.rollno=1 AND B.rollno=1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM