Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
I am getting an ambiguous error from this code.SELECT ContactName, ShipName, phone.shippers FROM orders, customers, shippers WHERE ShippedDate is null AND ShipCountry IN ('Mexico', 'USA', 'Canada')This is because phone is both present in shippers and customers. I want to show the shippers phone and not the customers, can anyone help me do this?
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2009-09-30 : 00:09:49
it should be:-
SELECT ContactName, ShipName, shippers.phone FROM orders, customers, shippers WHERE ShippedDate is null AND ShipCountry IN ('Mexico', 'USA', 'Canada')
themoney32
Starting Member
20 Posts
Posted - 2009-09-30 : 00:19:29
That is giving me incorrect Data. I have 5 company names of shippers in my shipping table, all with different phone numbers. I want to show the phone numbers of those companies that they used. This does not show that and gives me multiple rows that are not needed.
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2009-09-30 : 00:32:42
thats because you've not given any conditions in WHERE so its actually taking a CROSS JOIN between tables.if you can provide some sample data and also o/p you need out of them then i can provide query