0

I have 'select into' local variables in my MySQL database and it's only working on first variable. I am not sure why it's not working. 'select into' works like in SQL on MySQL?

SELECT 
    adresse_a, 
    adresse_b, 
    adresse_c,
    adresse_d_oid

        into    
            @a,
            @b,
            @c,
            @d_oid


    from table where oid = my_oid limit 1;

and it's in procedure / loop and always shows a - good value b,c,d is empty / null.

boski
  • 1,106
  • 3
  • 21
  • 44

1 Answers1

1

Your current syntax is perfectly fine. See it running in Fiddle at: http://sqlfiddle.com/#!2/a2581/25436

Using Mysql Workbench may create problem as reported here: https://stackoverflow.com/a/7338940/

For the Workbench, query could be re-written like this:

SELECT 
    @a:=adresse_a, 
    @b:=adresse_b
FROM `table` 
WHERE id = my_oid limit 1;
Community
  • 1
  • 1
Aziz Shaikh
  • 16,245
  • 11
  • 62
  • 79
  • Yes. It's working now. But I have another problem. As I said query is in procedure / loop. So now my Workbench shows me results (over 1000). It's possible to avoid that? – boski May 26 '14 at 07:30
  • @boski sorry, i am not sure about that. Can you find paging of results in the Workbench? – Aziz Shaikh May 26 '14 at 07:35
  • I deal with it in other way, by adding 'into @...' - then Workbench is not showing me sets of results – boski May 26 '14 at 11:28