View Single Post
Old 01-16-2008, 02:45 AM   #4 (permalink)
Karl
The Reckoner
Advanced Programmer Top Contributor 
 
Karl's Avatar
 
Join Date: Sep 2007
Posts: 437
Thanks: 22
Karl is on a distinguished road
Default

You could use an AS to rename the columns so that the union treats them as the same column. Such as:

sql Code:
SELECT
    student_id AS id,
FROM
    students
WHERE
    student_id = '8563' AND password= MD5('password')

UNION

SELECT
    admin_id AS id,
FROM
    admin
WHERE
    admin_id = '8563' AND password= MD5('password')
__________________
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
Karl is offline  
Reply With Quote