473,396 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Receiving Syntax Error using "OR" command

29
Hello,

I am attempting to call a particular table if the OR statement is used. When I try it gives me a Syntax error. Please assist?

Here is the code:
Expand|Select|Wrap|Line Numbers
  1. SELECT T_Physicians.TaxID, T_ECCcpt.CPTcode, T_ECCcpt.Charge, *
  2. FROM T_Physicians, T_ECCcpt
  3. WHERE (((T_Physicians.TaxID)="58-229xxxx"))
  4. OR
  5. SELECT T_Physicians.TaxID, T_SibleyCpt.CPTcode, T_SibleyCpt.Charge, *
  6. FROM T_Physicians, T_SibleyCpt
  7. WHERE
  8. T_Physicians.TaxID = 58-187xxxx;
  9.  
Adigga1
Oct 4 '08 #1
6 1688
Atli
5,058 Expert 4TB
Adigga1.

Please use [code] tags when posting your code examples.

Like:
[code] ...Code goes here... [/code]

Or better yet:
[code=sql] ...SQL goes here... [/code]

Thank you.
MODERATOR
Oct 4 '08 #2
Atli
5,058 Expert 4TB
That is not how the OR statement is mean to be used.

It is supposed to be used in a boolean statement, for example:
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM tbl
  2. WHERE id = 1 OR id = 2
  3.  
What you are attempting might require a stored procedure or some external API code.
It might be accomplished by a well designed JOIN, but I would need to know more about your data to be able to help figure that out.
Oct 4 '08 #3
adigga1
29
That is not how the OR statement is mean to be used.

It is supposed to be used in a boolean statement, for example:
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM tbl
  2. WHERE id = 1 OR id = 2
  3.  
What you are attempting might require a stored procedure or some external API code.
It might be accomplished by a well designed JOIN, but I would need to know more about your data to be able to help figure that out.

thank you and I apologize for the incorrect formatting;

What I'm attempting to establish is a condition i suppose whereby, when a particular TaxID is selected that represents ECC the corresponding ECC CPT table is referenced where i have to option to select the CPT code and price from that table.

I have all of the Physicians and TaxID; CPT and Prices loaded in their respective tables and fields.

I am seeking the correct coding to use in order to accomplish this. I am pretty new to coding so please be patient with me?

Thank you.
Oct 4 '08 #4
coolsti
310 100+
I do not know what your * in your select query is referring to, so I cannot give you a complete answer to this. I do not know if the way I am about to suggest is the most efficient way to handle this.

But assuming you do not have the * in the select query (you do not want any more fields) then the following may be a start of what you are looking for (but will not work as it is):

Expand|Select|Wrap|Line Numbers
  1. SELECT T1.TaxID, 
  2. IF (T1.ECC='yes',T2.CPTcode,T3.CPTcode) as CPTcode,
  3. IF (T1.ECC='yes',T2.Charge,T3.Charge) as Charge
  4. FROM T_Physicians T1, T_ECCcpt T2, T_SibleyCpt T3 
  5. WHERE (missing join conditions here)  
  6. AND (((T1.TaxID)="58-229xxxx")) 
  7.  
Here I do not know what the actual name of the attribute is in your main table for this ECC flag, nor do I know what values it can have. In the above example, I call it ECC, and I assume it has the value of 'yes' or 'no'. You can make changes to the above to fit your situation.

Also notice that I introduce here the aliases T1, T2 and T3 to make life simpler.

What is obviously missing here are missing join conditions for the three tables, and whether this strategy will work or not will depend on what the relationship is between the three tables involved (one to one, one to many, etc.).

What I do want to point out here in case it helps, is the use of an IF clause. Maybe a CASE clause would be more appropriate (in all my MySQL usage I have not ever used a CASE clause yet :) )
Oct 4 '08 #5
adigga1
29
Thank you very much coolsti ,

As a novice to this art, I appreciate the level of descriptive detail and time allocated to my challenge.

I will utilize and test this technique and post the results.

Again, thank you for your patience.

Adigga1
Oct 4 '08 #6
coolsti
310 100+
Glad to help where I can. I am not expert in all things and I assume (and welcome) others will jump in and correct me when I am wrong.

I don't always have the time for it but I feel a good explanation helps more than a short response giving only a solution.
Oct 5 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: tdi | last post by:
Ok, stupid question for the day. I'm reading the interview with Steve Moret and he says: "Once a lot of scripts started going in we knew there was no way we could back out of using Python." I'm...
3
by: Sara Khalatbari | last post by:
Hi! Suppose you're writing a module & writing the definition of each function in that module in " or """. for example: a) "This function does this & that" or: b) """This function does blah...
1
by: Matt | last post by:
Hi everyone, I'm using the command mysqlcheck --all-databases --auto-repair --silent and I see these warnings (listed below) on a daily occurrence. Is mysqlcheck causing these warnings? I...
2
by: Norman Fritag | last post by:
Hi there The below code executes some queries. As newbie I was wondering weather you are better of using connection execute or command execute to execute queries? I am asking as...
3
by: Cybertof | last post by:
Hello, I would like to return the good single value from a string value in these cases : Convert.ToSingle("23,30"); Convert.ToSingle("23.30"); // Conversion Error !!! The result should be...
5
by: comp.lang.php | last post by:
$orderBy = 's.app_date desc, s.last_name asc, s.first_name asc, s.mi asc'; if ($_REQUEST) { $ascArray = array('asc' => 'desc', 'desc' => 'asc'); // ARRAY OF ALL ORDERING POSSIBILITIES $junk =...
2
by: Serious_Practitioner | last post by:
Good day, and thank you in advance for any assistance. I'm having trouble with something that I'm trying for the first time. Using Access 2000 - I want to run a function either on the click of a...
37
by: jht5945 | last post by:
For example I wrote a function: function Func() { // do something } we can call it like: var obj = new Func(); // call it as a constructor or var result = Func(); // call it as...
5
by: inetquestion | last post by:
I am looking for a web interface for shell commands or shell scripts. Does anyone know of any exexisting php scripts which would solve this requirement? PHP form accepts input from a user, then...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.