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 > how do i use multiple lines with SET @var =

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-02-09, 07:52
BettingSherlock BettingSherlock is offline
Registered User
 
Join Date: May 2007
Posts: 78
how do i use multiple lines with SET @var =

Just hit the problem in a procedure that LIMIT only takes constants and not variables. So having to resort to a workaround being to put the query in a statement.

set @q = 'select * from t1 limit ?,?';
set @l1=10, @l2=1;
prepare q from @q;
execute q using @l1,@l2;

Problem is my actual query is 20 lines long so how do i put that in the set @ = without having to put the whole thing on one line.


set @q =
'select *
from t1
limit ?,?';

keeps giving me errors, what's the syntax for this ?
Reply With Quote
  #2 (permalink)  
Old 12-02-09, 09:06
BettingSherlock BettingSherlock is offline
Registered User
 
Join Date: May 2007
Posts: 78
set @q = "select *";
set @q = concat( @q , " from t1");
set @q = concat( @q , " limit ?,?");

Works.

Not very elegant is it... no nicer way ?
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