I have two queries I need to run:
SELECT COUNT(user_id) AS count_u FROM users WHERE username LIKE '$user'
SELECT COUNT(user_id) AS count_e FROM user WHERE user_email LIKE '$email'
Here were a couple of my failed attempts at trying to merge the queries:
SELECT COUNT(u1.user_id) AS count_u FROM users u1 WHERE
u1.username LIKE '$user' UNION SELECT COUNT(u2.user_id) AS count_e
FROM users u2 WHERE u2.user_email LIKE '$email'
SELECT COUNT(u1.user_id) AS count_u, COUNT(u2.user_id) AS count_e
FROM users u1, users u2 WHERE u1.username LIKE '$user'
AND u2.user_email LIKE '$email'
The first one gave me only the count_u column, but the rows showed accurate results. The second one gave me both columns, but they showed inaccurate results. I had thought about using JOINs, but the two queries seem totally distinct…there’s no common element. Know of any way to do this? Or should I just execute them separately?