1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

SQL Query Corker!!

Discussion in 'Databases' started by Weirfire, Oct 12, 2005.

  1. #1
    I've got a corker of a query that I'm trying to do. Not really sure whats the best way to go about this one but here's the description.


    I want to select the number of elements from table A where;

    the category field in table B = catx and has an id = idx which exists in table A as catid


    Table A
    id
    catid

    Table B
    id
    category
     
    Weirfire, Oct 12, 2005 IP
  2. frankm

    frankm Active Member

    Messages:
    915
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    83
    #2
    English to SQL:

    
    SELECT COUNT(*) 
    FROM tablea a, tableb b
    WHERE b.category = 'catx' 
        AND b.id = 'idx'
        AND a.catid = b.id
    Code (markup):
    should do the trick.
     
    frankm, Oct 12, 2005 IP
  3. frankm

    frankm Active Member

    Messages:
    915
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    83
    #3
    just curious: did it do what you wanted it to do ?
     
    frankm, Oct 12, 2005 IP
    Weirfire likes this.
  4. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #4
    It did indeed :) Thanks very much frank :D
     
    Weirfire, Oct 13, 2005 IP