View Single Post
  #1 (permalink)  
Old Mar 19th, 2008, 21:52
MrQuestions MrQuestions is offline
New Member
Join Date: Mar 2008
Location: states
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Simple SQL Select Query Question

Hi,

I'm trying to return all of rows by applying a simple query to my database, however not all of the rows are being returned. The simple SQL query is:

SELECT `id` FROM `tags` WHERE `tagname`='baseball'

The rows that are left out are those in which the variable being searched for is not the first record listed in the table for a corresponding record. For example, the query of the "tags" table (below) for 'baseball' above returns only ids 10 and 12. id 11 also has a tag "baseball" but it is not being returned. What do I need to add to my query in order to return all of the ids that correspond, and not just the "first" ones? Thanks in advance!

table: tags
id | tagname
10 | baseball
10 | free
10 | stars
11 | fakeguy
11 | baseball
11 | free
12 | baseball
12 | test
12 | fantasy
12 | sports
13 | basketball
13 | hoops
13 | ncaa
Reply With Quote