Click here to Skip to main content
15,885,137 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am creating a login page,

tables:
database has tables "student" and "faculty"

schema:
"student" table has columns "sid,spass,sfname.....etc."
"faculty" table has columns "fid,fpass,ffname......etc"

Problem---
I want to create a temporary table which contains all "sid,fid" as "username" and all "spass,fpass" as "password" column. thus resultant table should have only 2 columns containing username and password of all members , witch i can use further to apply validation for successful login.
So what query i have to write to extract that table ??
Posted
Updated 29-Dec-15 3:51am
v2
Comments
ZurdoDev 29-Dec-15 9:52am    
Use union.

In Microsoft SQL it would be

SELECT sid, spass
FROM student
UNION
SELECT fid, fpass
FROM faculty

MySql is probably very similar.

1 solution

I tweaked a little and found out the exact query i was looking for , thank you for your help pal, here is the query for future out fellas:

JavaScript
SELECT sid AS allusername,
 spass AS allpassword 
 FROM student 

UNION 

SELECT fid AS allusername, 
 fpass AS allpassword 
 FROM faculty
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900