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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.