| | |
SQL Query Analyzer Problem
Please support our Database Design advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Aug 2007
Posts: 3
Reputation:
Solved Threads: 0
The program I use is housed in a SQL Database. What I am trying to do is term Members based on meeting 2 guidelines (PCP and Insurance). WHat I want to do is term a group of members that have the same PCP and Insurance plan. This data is broken up into 3 different databases - Pcphistory, Eligibilityhistory, and Benefitplans. I have been struggling, because I have never had to do this before. This is what I started...
When I run this Query in SA, I get the following error: Server: Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'from'.
This is running on SQL 2000... I am truly pulling my hair out, as there isn't anyone who uses the software that we do and the programmer bailed on us!
update eligibilityhistory set terminationdate='09/30/2007' from eligibilityhistory inner join benefitplans on eligibilityhistory.benefitplanid =benefitplans.benefitplanid where benefitplans.healthplanid='BCN' from eligibilityhistory inner join pcphistory on eligibilityhistory.memberid = pcphistory.memberid where pcphistory.providerid='1532' and terminationdate is null
When I run this Query in SA, I get the following error: Server: Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'from'.
This is running on SQL 2000... I am truly pulling my hair out, as there isn't anyone who uses the software that we do and the programmer bailed on us!
This is now syntactically correct, whether it does what you require I can only guess without DDL and expected results from you.
I recommend you run this first to see what is going to be updated before you actually run the update above.
update
eligibilityhistory
set
terminationdate='09/30/2007'
from
eligibilityhistory
inner join benefitplans
on eligibilityhistory.benefitplanid=benefitplans.benefitplanid
inner join pcphistory
on eligibilityhistory.memberid=pcphistory.memberid
where
benefitplans.healthplanid='BCN'
and pcphistory.providerid='1532'
and terminationdate is nullI recommend you run this first to see what is going to be updated before you actually run the update above.
Select
*
from
eligibilityhistory
inner join benefitplans
on eligibilityhistory.benefitplanid=benefitplans.benefitplanid
inner join pcphistory
on eligibilityhistory.memberid=pcphistory.memberid
where
benefitplans.healthplanid='BCN'
and pcphistory.providerid='1532'
and terminationdate is null Last edited by hollystyles; Aug 30th, 2007 at 9:18 am.
This means terminationdate is a column name in more than one of the three tables in your SQL Query. You need to be Specific (not ambiguous) and prefix it with the table name and a period. Hint double click on the error message in the lower pane of Query Analyzer it will take you to the line that has the error.
You will need to do this in the 'where' clause. So if it's the terminationdate column in the pcphistory table that must be null put
You will need to do this in the 'where' clause. So if it's the terminationdate column in the pcphistory table that must be null put
pcphistory.terminationdate is null in the where clause. Last edited by hollystyles; Aug 30th, 2007 at 9:41 am.
![]() |
Similar Threads
- sql query problem with MS Access and C# (C#)
- how to delete duplicate record in a table by using SQL query (MS SQL)
- SQL query problem with WHERE clause (ASP)
- Accessing ADSI Query from ASP page (ASP)
- sql query updating problem (Visual Basic 4 / 5 / 6)
- Javascript array from sql query (JSP)
- Please help me out with MySQL query (MySQL)
- PHP/SQL query help (PHP)
- Retreiving variables from a sql query into a form (PHP)
Other Threads in the Database Design Forum
- Previous Thread: DB design for friends network
- Next Thread: Design help plz
| Thread Tools | Search this Thread |






