Welcome Guest, Not a member yet? Register   Sign In
sql statement
#1

[eluser]mikeyhell[/eluser]
I'm rescripting and application and ran into an sql statement that's stumped me. Can someone help me understand what's going on here:

Code:
SELECT hotlead_flag, ve.*
FROM vendor_email_new ve
JOIN vendor_new using (email)
WHERE sent_email is null
#2

[eluser]Jay Turley[/eluser]
[quote author="mikeyhell" date="1205813256"]I'm rescripting and application and ran into an sql statement that's stumped me. Can someone help me understand what's going on here:

Code:
SELECT hotlead_flag, ve.*
FROM vendor_email_new ve
JOIN vendor_new using (email)
WHERE sent_email is null
[/quote]

it is selecting hotlead_flag from the vendor_new table, and then selecting everything (ve.*) from the vendor_email_new table which has been aliased as ve. The tables are joined on the email column and the final criteria is if the vendor_new.sent_email column is null.

You can think of it this way (though I would probably enumerate the columns in the vendor_email_new table instead of using *):

Code:
SELECT
    vn.hotlead_flag, ve.*
FROM
    vendor_email_new ve
JOIN
    vendor_new vn
ON
    ve.email = vn.email
WHERE
    vn.sent_email IS NULL




Theme © iAndrew 2016 - Forum software by © MyBB