Go Back   Forum Care Forums > Development Reference Area > MySQL Discussion

Reply
 
LinkBack Thread Tools Display Modes
Where condition syntax?
Old
  (#1)
GarryJones
Guest
 
Posts: n/a
Default Where condition syntax? - 06-04-2007, 07:48 AM

This works fine

$ml_collect='SELECT * FROM ml_lopp LEFT JOIN scfmforening ON
(scfmforening.scfmnum=ml_lopp.scfmnum) LEFT JOIN ml_newtidplats ON
(ml_newtidplats.loppnum=ml_lopp.loppnum) ORDER BY date1,
ml_lopp.loppnum';

And I can process and get the records starting with this...

$ml_upg=mysql_query($ml_collect);

Now I need to add this Where statement in the code.

WHERE sank2006 = 'Ansökt' -

(I know I need to escape the quotes with backslash, but Its misfiring
and not picking up records)

I am trying this

$ml_collect='SELECT * FROM ml_lopp WHERE sank2006 = \'Ansökt\' LEFT
JOIN scfmforening ON (scfmforening.scfmnum=ml_lopp.scfmnum) LEFT JOIN
ml_newtidplats ON (ml_newtidplats.loppnum=ml_lopp.loppnum) ORDER BY
date1, ml_lopp.loppnum';

Where am I going wrong?

Grateful for any help in this matter

Garry Jones
Sweden

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: Where condition syntax?
Old
  (#2)
Michael Austin
Guest
 
Posts: n/a
Default Re: Where condition syntax? - 06-04-2007, 07:48 AM

GarryJones wrote:
> This works fine
>
> $ml_collect='SELECT * FROM ml_lopp LEFT JOIN scfmforening ON
> (scfmforening.scfmnum=ml_lopp.scfmnum) LEFT JOIN ml_newtidplats ON
> (ml_newtidplats.loppnum=ml_lopp.loppnum) ORDER BY date1,
> ml_lopp.loppnum';
>
> And I can process and get the records starting with this...
>
> $ml_upg=mysql_query($ml_collect);
>
> Now I need to add this Where statement in the code.
>
> WHERE sank2006 = 'Ansökt' -
>
> (I know I need to escape the quotes with backslash, but Its misfiring
> and not picking up records)
>
> I am trying this
>
> $ml_collect='SELECT * FROM ml_lopp WHERE sank2006 = \'Ansökt\' LEFT
> JOIN scfmforening ON (scfmforening.scfmnum=ml_lopp.scfmnum) LEFT JOIN
> ml_newtidplats ON (ml_newtidplats.loppnum=ml_lopp.loppnum) ORDER BY
> date1, ml_lopp.loppnum';
>
> Where am I going wrong?
>
> Grateful for any help in this matter
>
> Garry Jones
> Sweden
>



$ml_collect = "SELECT * FROM ml_lopp LEFT JOIN scfmforening ON ";
$ml_collect .= "(scfmforening.scfmnum=ml_lopp.scfmnum) LEFT JOIN ";
$ml_collect .= "ml_newtidplats ON (ml_newtidplats.loppnum=ml_lopp.loppnum) ";
$ml_collect .= "WHERE ml_lopp.sank2006 = \'Ansökt\' ";
$ml_collect .= "ORDER BY ml_lopp.date1, ml_lopp.loppnum";

Note the position of the WHERE clause.

--
Michael Austin
Database Consultant
Domain Registration and Linux/Windows Web Hosting Reseller
http://www.spacelots.com
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top