0

I have requirement in my project to extract the rows in sql format. I have multiple select statements with same WHERE condition. Is it possible to set the WHERE condition in a param and make use of it in the select statements?

@set maxrows -1;
@export on;
@export set filename="C:\test\test12.sql" appendfile="true" format="sql";

SELECT ee.employeeId, ee.firstname, ee.lastName, ee.designation 
FROM employee ee
WHERE ee.employeeId in (1, 2, 3, 4);

SELECT lib.employeeId, lib.bookId 
FROM library lib
WHERE lib.employeeId in (1, 2, 3, 4);

SELECT lv.employeeId, lv.LeaveApplicationDate, lv.NoOfLeaves
FROM Leaves lv
WHERE lv.employeeId in (1, 2, 3, 4);

@export off;

As you can observe here, the WHERE condition is constant for each of SELECT Statements. Is it possible to set in a param and make use of the same in all the select statements?

Example (below will not work):

@set maxrows -1;
@set employeeIds = 1, 2, 3, 4;
@export on;
@export set filename="c:\Work\test124536.sql" appendfile="true" format="sql";

SELECT ee.employeeId, ee.firstname, ee.lastName, ee.designation 
FROM employee ee
WHERE ee.employeeId in (employeeIds);

@export off;
Srinivas Lakshman
  • 469
  • 2
  • 4
  • 21
  • 1
    ou should change your tags that is not standard mysql. I thin your are ussing dbvisualizer, so use that as tag – nbk Sep 12 '19 at 21:13
  • Thanks @nbk for the reply. I'm using dbvisualizer for a mysql database. I will tag dbvisualizer as well. – Srinivas Lakshman Sep 13 '19 at 13:12
  • @SrinivasLakshman, please check the users guide on the support for the various DbVisualizer client side commands. http://confluence.dbvis.com/display/UG100/Using+Client-Side+Commands. For support please use Help->Contact Support in DbVisualizer. – roger Sep 19 '19 at 07:12

0 Answers0