Jump to content

[SOLVED] SELECT once from one table but not both


sKunKbad

Recommended Posts

MySQL client version: 5.0.45

 

Simplified for the question:

CREATE TABLE `admins` (
	  `username` varchar(12) NOT NULL
	)

CREATE TABLE `users` (
	  `username` varchar(12) NOT NULL,
	)

 

SELECT users.username, admins.username
FROM users, admins
WHERE users.username = 'skunk'
OR admins.username = 'skunk'

 

I'm just trying to see if the username 'skunk' belongs to either an admin or a user, but I get a result set like this:

username

username

skunk

admin1

skunk

admin2

skunk

admin3

 

How can I make this query just return one row that matches 'skunk' and that's it. Like this:

 

username

skunk

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.