General Development

Help me make an SQL Statement – DeathFox

DeathFox
Member

Posts: 57
From:
Registered: 04-25-2006
I got two tables, Physical and Dental

Physical has Description, Date, Pet_Number and Dental has the same

How Do I make it so it will look like this

Physical Description | Physical Date
Dental Description | Dental Date

And their ordy by is through their date. I tried to cross join but this will be the result

Physical Description | Physical Date | Dental Description | Dental Date


Plz help me make an SQL Statement for this


MastaLlama

Member

Posts: 671
From: Houston, TX USA
Registered: 08-10-2005
quote:
Originally posted by DeathFox:
I got two tables, Physical and Dental

Physical has Description, Date, Pet_Number and Dental has the same

How Do I make it so it will look like this

Physical Description | Physical Date
Dental Description | Dental Date

And their ordy by is through their date. I tried to cross join but this will be the result

Physical Description | Physical Date | Dental Description | Dental Date


Plz help me make an SQL Statement for this


Well, if you're doing this in Microsoft SQL Server 2000 or higher (maybe even lower) you can do the following. I'm not sure if it will work on other database platforms though...


SELECT Description, Date FROM Physical
UNION ALL
SELECT Description, Date FROM Dental
ORDER BY Date

I hope this helps

supercoder

Member

Posts: 37
From:
Registered: 08-20-2007
its hard to tell what u r trying to do, is Physical & Dental 1 to 1 keyed on Pet_Number?
or maybe,
select Physical.Description || "|", Physical.Date || char(10) || char(13),
Dental.Description || "|" , Dental.Date from Physical, Dental
where Physical.Pet_Number = Dental.Pet_Number
order by Physical.Date

------------------
>>>--supercoder--<<<

DeathFox
Member

Posts: 57
From:
Registered: 04-25-2006
Thanks