SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Guru
    Join Date
    Sep 2008
    Posts
    977
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    inner join problem

    Hi,

    I am trying to make an inner join get me only the results from two tables, where there is a match.

    trouble is, it is bringing back all possible records, which is no use.

    the first query brings back the correct results from one table

    the second query has the inner join but it brings back every possible record.

    Code MySQL:
    SELECT business_id
    , div_tag
    FROM page_blocks_to_scripts_set
    WHERE business_id = 456
    AND script_name = 'mainpage'
    AND live_dev = 'dev'
    AND is_equal_column = 'yes'
    ORDER BY sequence_number

    brings back three rows as it should/ought to.

    Code MySQL:
    SELECT 
    business_id
    , div_tag
    FROM page_blocks_to_scripts_set AS tset
    inner 
    join website_scripts_to_tags AS tags  
      on tags.script_name = tset.script_name
    and tags.script_name = 'mainpage'
    where tset.business_id = 456
    and tset.live_dev = 'dev'
    and tset.is_equal_column = 'yes'
    and tset.script_name = 'mainpage'

    brings back all records, seemingly, ignoring the where clause

    what am I missing, please?

    bazz

  2. #2
    SitePoint Guru
    Join Date
    Sep 2008
    Posts
    977
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    silly oversight. I needed to include a join on a third table, to relate the div_tags, with the page_blocks.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •