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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Data from 2 tables

Author  Topic 

taylo
Yak Posting Veteran

82 Posts

Posted - 2001-02-27 : 21:31:18
Please do not send me to this URL. It is not solving the problem
http://sqlteam.com/item.asp?ItemID=239

I am re-developing a web site that has a database that was not designed properly.
I have to query the database and return matching records from 2 tables. It works like this. A user seraches the database for drug names. Table A has the Real Drug Names and table B has the generic drug names. I need to find all the matching records in table A and also return all the matching generic drugs in table B. All of this has to be ordered of course. I have tried using UNION which I have little experience with but it is not working. It either returns all the records or none.

Select DrugName from Primary_Drug_Table
UNION Select GenericName from Generic_Drug_Table
Where Left(Primary_Drug_Table.DrugName,"&dnameL&") LIKE '%"&dname&"%'

Thanks,


Rob

   

- Advertisement -