codehaven - php snippets - coding help
Generic filters
Exact matches only
  • Inner Join 2 tables to 3 tables -Add another table

    14th August 2014


    mysql codehaven category

    Best way to combine 3 tables data together I have found is the following script.

    Before you do it the hard way try the easy way…just add a WHERE CLAUSE

    This SQL joins two tables together where the campaign id is the same.

    If the results back are many, then I may want to check another table to see if something is true.

    We can add another join statement “INNER JOIN table3 ON table3.campaignid = table1.campaignid” as long as it has the campaignid in it also. Then we just add the statement “AND table3.impressions_month != 0”

    We could join many tables like this…….

    ORIGINAL VERSION (Two tables)

    UPDATED VERSION (three tables)

    Another more full example

    If you have a fname in both tables you are trying to get results from, you can do this….

    Was this code snippet helpful?