sql - Selecting data from two mysql tables in one query -
I have two tables, landlords and properties are my property table; ID, address, postcode, lease, and landlord ID The problem I have is: If I want to find all the qualities that Mr.Spina is in the form of their landlord then I would like to find the names of the landlords to find the name "spin" Which is saved in the property's database, from which I can remove the details details.
I thought it would work, but it's not right:
& gt; Select property property.ID, property.address, property.postcode, property. Please, landlords. First name, landlords. Join landlords from property properties in INNER landlords. First name '% spina%' or '% spina%' like landlords.lastName
I have attached images of table structures.
Landlords:
Permission of only one link
Properties:
Entering "Spina" in the field The result should be: Only one link permission
Here is my removed code ...
pre> Many thanks in advance! It looks like you use & gt; If ($ Field == "Landlord") {& gt; & Gt; $ Sql = "SELECT property.ID, property.address, property.postcode,> property, please, landlines. First name, & gt; landlords .name". $$ "INNER" include landlords in landlords, like first name & gt; '%'. $ Q "% 'or landlords. Anonymous & gt; like'%. '$ Q. "%'"; & Gt; } Other {& gt; $ Sql = "SELECT * FROM" $ Make "WHERE" $ field "likes'%". $ Q "% '"; & Gt; } // and special case $ result = & gt; Mysql_query ($ sql); & Gt; Repeat "$ sql"; & Gt; Now "Table boundary = '1'"> "> <<<<>>
Landlord "; & Gt; & Gt; While ($ line = & gt; mysql_fetch_array ($ result)) & gt; {& Gt; Echo "& lt; tr & gt;"; & Gt; Echo "& lt; td & gt;" . $ Line ['id'] "& lt; / td & gt;"; & Gt; Echo "& lt; td & gt;" . $ Line ['address'] "& lt; / td & gt;"; & Gt; Echo "& lt; td & gt;" . $ Line ['postcode']. "& Lt; / td & gt;"; & Gt; Echo "& lt; td & gt;" . $ Line ['lease'] "& lt; / td & gt;"; & Gt; Echo "& lt; td & gt;" . $ Line ['first name']. "" $ Line ['last name']. "& Lt; / td>"; & Gt; Echo "& lt; / tr & gt;"; & Gt; } Resonates "& lt; / table & gt;"; & Gt; & Gt; Mysql_close (); INNER JOIN
wrongly; Whatever you want is something like this:
SELECT property.ID, property.address, property.postcode, property. Please, landlords. First name, landlords. Join landlords on property from property INNER landlords I ID = property.landlord WHERE landlords. First name '% spina%' or '% spina%' like landlords.lastName
Comments
Post a Comment