Results 1 to 2 of 2
  1. #1
    Join Date
    May 2007
    Posts
    80

    Unanswered: 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 ?

  2. #2
    Join Date
    May 2007
    Posts
    80
    set @q = "select *";
    set @q = concat( @q , " from t1");
    set @q = concat( @q , " limit ?,?");

    Works.

    Not very elegant is it... no nicer way ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •