If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > ACCESS to MySQL: Query Conversion Help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-28-05, 15:12
mailto mailto is offline
Registered User
 
Join Date: Jan 2005
Posts: 1
Exclamation ACCESS to MySQL: Query Conversion Help

I have an ACCESS query that I am trying to convert to MySQL. See if you can help:

ACCESS Query-->
$query1 = odbc_exec($odbc1, "SELECT [CONCAT], IIF(Sum([LMU])>0,Format(100*Sum([LM])/Sum([LMU]),'000.0'),Format(100*0,'000.0')) AS [QUERY_LM] FROM [table1] WHERE [PLACE] LIKE '$place%' GROUP BY [CONCAT] ORDER BY [CONCAT] ASC") or die (odbc_errormsg());

Possible MySQL Query [d/NOT work??]-->
$query1 = "SELECT CONCAT, IF(SUM(LMU)>0,100*SUM(LM)/Sum(LMU),100*0) AS QUERY_LM FROM `table1` WHERE PLACE LIKE '$place%' GROUP BY CONCAT ORDER BY CONCAT ASC";
$result1 = mysql_query($query1) or die("Error. " . mysql_error());

As you may notice, I have not used the equivalent of FORMAT() in MySQL to simply this conversion, but it still doesn't work.

--Mailto
Reply With Quote
  #2 (permalink)  
Old 01-29-05, 01:06
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
CONCAT is a the name of a function in mysql, so you have to backtick it
Code:
select `CONCAT`
     , case when Sum(LMU) > 0
            then 100.0*Sum(LM)/Sum(LMU)
            else 0 
         end        as QUERY_LM 
  from table1 
 where PLACE like '$place%' 
group 
    by `CONCAT` 
order 
    by `CONCAT` asc
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On