Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 database search help needed.
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Jason
New Member

80 Posts

Posted - 20 February 2002 :  18:56:14  Show Profile
Hi there

I need to produce a login script that searches 3 tables in a DB and return the name of the table the result was from.

My database has many tables including the follwing 3:

Clients
Managers
Contractors.

I basically need to search through these 3 tables to find the match (or not) but them need to know what table they have come from. It would be easy if they were all in the same table with a identifier in the same row but the tables need to be constructed this may because of other factors.

My question is, can I return the name of the table the result came from without inserting an extra field in each of them with the table name in it so I can retrieve it with the search?

Once I know what table they are from I can assign differnt permissions.

Any ideas of a good query I can run to achieve this?

Thanks
Jason


Jason
New Member

80 Posts

Posted - 20 February 2002 :  20:31:12  Show Profile
Thanks for the reply but I found exactly what I needed here:
http://www.sqlteam.com/item.asp?ItemID=513

Cheers
Jason

Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 21 February 2002 :  07:08:25  Show Profile  Send ruirib a Yahoo! Message
Just realized I had left the "tablename" out of the query (), and you needed that.

Here goes the changed code:



SELECT * FROM
(SELECT ID,USERNAME,PASSWORD, "CLIENTS" AS TABLENAME FROM CLIENTS
UNION
SELECT ID,USERNAME,PASSWORD,"MANAGERS" AS TABLENAME FROM MANAGERS
UNION
SELECT ID,USERNAME,PASSWORD,"CONTRACTORS" AS TABLENAME FROM CONTRACTORS)
WHERE (USERNAME="MySearchName") AND (PASSWORD="MySearchPassword");




Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.25 seconds. Powered By: Snitz Forums 2000 Version 3.4.07