RE: Where statements (UNCLASSIFIED)

Classification: UNCLASSIFIED
Caveats: NONE
Thanks. I’ll give this a try.
Tim Payne
Stat Team Lead - ORSA
USACR/SC
(334)255-2075
email: james.t.payne20.civ@mail.mil
CAUTION: This electronic transmission may contain information protected by deliberative process or other privilege, which is protected from disclosure under the Freedom of Information Act, 5 U.S.C. § 552. The information is intended for the use of the individual or agency to which it was sent. If you are not the intended recipient, be aware that any disclosure, distribution or use of the contents of this information is prohibited. Do not release outside of DoD channels without prior authorization from the sender. The sender provides no assurance as to the integrity of the content of this electronic transmission after it has been sent and received by the intended email recipient. -----Original Message-----
From: Joshua Liong [mailto:bounce-JoshuaLiong@toadworld.com] Sent: Wednesday, March 19, 2014 7:41 PM
To: toaddatapoint@toadworld.com
Subject: RE: [Toad Data Point - Discussion Forum] Where statements
RE: Where statements Reply by Joshua Liong To tpayne:
I believe I understand your issue. There are ways of addressing your problem, though I could not tell at a glance which database platform you were inquiring about. The coding syntax I’m writing will be catered to SQL Server.
You can type out a series of SQL Statements where you only need to assign the variable just once, as you originally requested!
Declare a variable
/* IN SQL Server, declare with “DECLARE @var DATATYPE” / DECLARE @myVariable varchar(50);
/
Assign it a value /
SET @myVariable = ‘I%’;
/
Use a statement! /
SELECT * FROM ADDRESS
WHERE (CITY LIKE @myVariable) OR (STATE LIKE @myVariable);
It sounds like you’re typing the same statements quite a bit. It may helpful to use SQL to simply prompt you while it is executing instead of typing in the value before execution. Below is an example of the syntax with two approaches of doing the same thing.
Use an unassigned unnamed variable
/
IN SQL Server, declare with “DECLARE @var DATATYPE” / DECLARE @myVariable varchar(50);
/
Get prmopted for a value every execution / SET @myVariable = ?; / Use a statement! /
SELECT * FROM ADDRESS
WHERE (CITY LIKE @myVariable) OR (STATE LIKE @myVariable);
Use a unassigned named variable
/
IN SQL Server, declare with “DECLARE @var DATATYPE” / DECLARE @myVariable varchar(50); / Use a statement! */
SELECT * FROM ADDRESS
WHERE (CITY LIKE :InputVar) OR (STATE LIKE :InputVar);
Again, syntax varies depending on the database platform you’re using. I hope this post is a good start to achieve your needs.
-Joshua Liong
To reply, please reply-all to this email.
Stop receiving emails on this subject.
Or Unsubscribe from Toad Data Point - General notifications altogether. Toad Data Point - Discussion Forum Flag this post as spam/abuse. Classification: UNCLASSIFIED
Caveats: NONE