I am trying to create an SQL query that compares two databases with each other, however also will not result in a query failure if one of the database rows has not been created elsewhere yet.
Here's what I've gotten so far (a bit of pseudo code)
$Query="SELECT * FROM campaigns,statistics WHERE statistics.dataDate = '$todaysDate' OR statistics.dataDate DOES NOT EXIST AND where campaigns.campaignName = 'example'";
The "DOES NOT EXIST" part is where I need the help, how can I create a query that allows the query to continue with more checks if the row has not been created yet?
Thanks very much for any suggestions! I've taken a look around and can't find a solution that checks if the row doesn't exist inside of the query (will be needed for when the query is built out a bit further)
Thanks again,
Ash
edit:
To clear up any confusion here's a second example:
`$Query="SELECT * FROM campaigns,statistics WHERE campaigns.campaignName = '$randomVar' AND (campaigns.budget > statistics.budget OR statistics.budget DOES NOT EXIST )";`
I have created this example showing that if the budget does not exist (we would treat it as 0) and still return the results because the budget field hasn't been created yet elsewhere in the platform. If I run the query without this extra "OR" it will look something like this:
`$Query="SELECT * FROM campaigns,statistics WHERE campaigns.campaignName = '$randomVar' AND (campaigns.budget > statistics.budget)";`
The problem with this is that in my platform so far the statistics.budget is not always created before this query is ran, therefor if it doesn't have a row I'm happy for the query to treat it as 0
Thanks!
Ash