Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple fields from multiple tables have unique names

Status
Not open for further replies.

DigitalBuilder

Programmer
Apr 7, 2005
33
NZ
I want to have multiple fields from multiple tables have unique names or a way to uniquely identify them when using table1.*, table2.*

Any ideas?

e.g. Order gets the second order and not the first

I realise order has to be escaped in [order] when doing the sql but not for the RS

Example data
1213FlatType101Flat Information11912Available: Whole Flat01213FlatType101Flat Information12012Available: Partial, Shared Resources01213FlatType101Flat Information12112Available: Partial, Individual Resources01213FlatType101Flat Information12212Wanted, Whole Flat01213FlatType101Flat Information12312Wanted, Partial, Shared Resources01213FlatType101Flat Information12412Wanted, Partial, Individual Resources0


It will be for
 
It is not best practice to use SELECT * - you should explicitly state which columns you want. That way you can give each one an alias and solve your problem:

Code:
SELECT t1.c1 AS t1c1,
  t1.c2 AS t1c2,
  t2.c1 AS t2c1,
  t2.c2 AS t2c2
FROM t1 JOIN t2 ON ...

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top