From clause

The following doesn' work, in the sense that is expecting a FROM clause.
I would like to show all the fields declared after the first SELECT, thus CH_DOC_ID (that could be drop_trigger or ch_doc_id) and title, status and tool.
Here below my code:
SELECT
CASE WHEN PCMS_CHDOC_DATA.TOOL='ICD' THEN
PCMS_CHDOC_DATA.DROP_TRIGGER
ELSE PCMS_CHDOC_DATA.CH_DOC_ID
END CH_DOC_ID,
TITLE,
STATUS,
TOOL
FROM
(SELECT PCMS_CHDOC_DATA.TITLE,
             PCMS_CHDOC_DATA.STATUS,
             PCMS_CHDOC_DATA:TOOL,
             PCMS_CHDOC_DATA.DROP_TRIGGER,
             PCMS_CHDOC_DATA.CH_DOC_ID
FROM
PCMS_CHDOC_DATA
WHERE
--                  PCMS_CHDOC_DATA.STATUS <> 'CLOSED' and
                  PCMS_CHDOC_DATA.TOOL = 'ICD' and
                  lower(PCMS_CHDOC_DATA.TITLE) LIKE  ('auto%pop%') OR
                  lower(PCMS_CHDOC_DATA.TITLE) LIKE ('%wiring%check%')
order by CH_DOC_ID

It gives the error ORA-00904: "PCMS_CHDOC_DATA.CH_DOC_ID : invalid identifier [database vendor code: 0904]ORA-00904: string: invalid identifier
Cause: The column name entered is either missing or invalid.
Please check whether column name is correct/present in the table. Try below code.
{code}
SELECT
CASE WHEN TOOL='ICD' THEN
DROP_TRIGGER
ELSE CH_DOC_ID
END,
CH_DOC_ID,
TITLE,
STATUS,
TOOL
FROM
(SELECT PCMS_CHDOC_DATA.TITLE,
PCMS_CHDOC_DATA.STATUS,
PCMS_CHDOC_DATA.TOOL, --PCMS_CHDOC_DATA:TOOL, -- replace a colon with a dot
PCMS_CHDOC_DATA.DROP_TRIGGER,
PCMS_CHDOC_DATA.CH_DOC_ID
FROM
PCMS_CHDOC_DATA
WHERE
-- PCMS_CHDOC_DATA.STATUS 'CLOSED' and
PCMS_CHDOC_DATA.TOOL = 'ICD' and
lower(PCMS_CHDOC_DATA.TITLE) LIKE ('auto%pop%') OR
lower(PCMS_CHDOC_DATA.TITLE) LIKE ('%wiring%check%')
order by CH_DOC_ID)
{code}
Regards,
Avinash
Edited by: Avinash Tripathi on Nov 16, 2010 8:11 PM

Similar Messages

  • Is there a way to use dynamic built string in the "from" clause

    Hi all, im having one problem and now, im not sure how to solve it easily at all... :) Is there someone that would be so kind and put a eye on it? ..thx
    I have plsql proc, in which i have a list of table_names. For each of that table i need to run a query that will retrieve me a list of values and for each of that value i need to do something.
    If i can be more specific about the problem -> each of that table is built as key_column, value_columns, day,starttime. For a key per table there are 4 records per hour - every quarter. Im truncating those quarters to full-quarter (minutes => 0->14 = 0min; 15->29 = 15min, 30->44 = 30, 45->59=45)
    example
    i get for one key and specific hour four records at 15:01;15:16;15:31;15:46 => i truncate em to 15:00;15:15;15:30;15:45..Sometimes there is a problem with the tool that is generating those data for me, and one quarter could be moved a little - so i get data like 15:01;15:16;15:29;15:46 => after i truncate the times i get duplicates in second quarter. It also can happen like this : 23:00; 23:14; 23:29; 23:44; 23:59 => totaly bad => cos the last one supposed to be as 0:00 next day, ..and 23:14 as 23:15...So...that was a problem - and solution -> i wanted to create plsql that will find those hours in each table i ve defined, and for each problem hour i make some fixes - update the bad time ...
    ..and i have problem - can i put an dynamic built table_name in the "from" clause?
    example how i wanted to do that:
    declare
         type t_objectName     is table of varchar2(030) index     by pls_integer;
         l_tableName              t_objectName;
    begin
    l_tableName(1) := 'tmphlrgl';
    l_tableName(2) := 'tmprcfgl';
    l_tableName(3) := 'tmprcfbs';
    l_tableName(4) := 'tmpvlrgl';
    for i in (select evtime from (select day,trunc_quarter(evtime) evtime,m_id from l_tableName(i) group by day,trunc_quarter(evtime),m_id having count(*)>1) order by evtime) loop
    --some other conditions and the update...
    end loop;
    end;
    /I cannot use the l_tableName(i) for FROM ...get an error...I was thinking to build it as dynamic sql and execute immediate into some kind of object that can store mutliple lines, from which i would in the FOR cycle get the data...But im not sure if this could be done in plsql...
    thanks for your time and help..
    d.

    declare
    c sys_refcursor;
    begin
    for i in 1..4 loop
    open c for 'day,trunc_quarter(evtime) evtime,m_id
    from ' || l_tableName(i) ||
    'group by day,trunc_quarter(evtime),m_id having
    count(*)>1) order by evtime';Just to high light SELECT is missing that all
    OPEN c FOR ' SELECT day,trunc_quarter(evtime) evtime,m_id
              FROM' || l_tableName(i) ||
    'GROUP BY day,trunc_quarter(evtime),m_id  HAVING  count(*)>1)   ORDER BY evtime';

  • Is it possible to create a view where table in the From clause changes name

    is it possible to create a view from a from a table like this
    create view my_view as select id, col1, col2, result from <<my_latest_cacahe_table>>;
    the table in the from clause changes the name .
    I have another table which indicates the the latest name of my cache tables. Always there are two records there. The latest one and previous one.
    select * from cache_table_def
    table_name cache_table_name refresh_date
    my_table cache_table245 1/23/2012
    my_table cache_table235 1/22/2012
    create table cache_table_def (table_name varchar2(25), cache_table_name varchar2(25), refresh_date date);
    insert into cache_table_def values( 'my_table','cache_table245','23-jan-2012');
    insert into cache_table_def values ( 'my_table','cache_table546','22-jan-2012');
    create table cache_table245 (id number, col1 varchar2(50), col2 varchar2(20), result number);
    insert into cache_table245 values(1, 'test123', 'test345',12.12);
    insert into cache_table245 values (2, 'test223', 'test245',112.12);
    create table cache_table235 (id number, col1 varchar2(50), col2 varchar2(20), result number);
    insert into cache_table235 values (1, 'test123', 'test345',92.12);
    insert into cache_table235 values (2, 'test223', 'test245',222.12);
    what I need to do is find the latest cache_table name for my_table and use that in my view defintion
    When user select from the the view it always reurns the data from the latest cache_table
    is it possible to do something like this in oracle 11g?
    I have no control on the cache tables names. that is why I need to use the latest name from the table.
    Any ideas really appreciated.

    I've worked up an example that does what you ask. It uses the SCOTT schema EMP table. Make two copies of the EMP table, EMP1 and EMP2. I deleted dept 20 from emp1 and deleted dept 30 from emp2 so I could see that the result set really came from a different table.
    -- create a context to hold an environment variable - this will be the table name we want the view to query from
    create or replace context VIEW_CTX using SET_VIEW_FLAG;
    -- create the procedure specified for the context
    - we will pass in the name of the table to query from
    create or replace procedure SET_VIEW_FLAG ( p_table_name in varchar2 default 'EMP')
      as
      begin
          dbms_session.set_context( 'VIEW_CTX', 'TABLE_NAME', upper(p_table_name));
      end;
    -- these are the three queries - one for each table - none of them will return data until you set the context variable.
    select * from emp where 'EMP' = sys_context( 'VIEW_CTX', 'TABLE_NAME' );
    select * from emp1 where 'EMP1' = sys_context( 'VIEW_CTX', 'TABLE_NAME' );
    select * from emp2 where 'EMP2' =  sys_context( 'VIEW_CTX', 'TABLE_NAME' )
    -- this is how you set the context variable depending on the table you want the view to query
    exec set_view_flag( p_table_name => 'EMP' );
    exec set_view_flag( p_table_name => 'EMP1' );
    exec set_view_flag( p_table_name => 'EMP2');
    -- this will show you the current value of the context variable
    SELECT sys_context( 'VIEW_CTX', 'TABLE_NAME' ) FROM DUAL
    -- this is the view definition - it does a UNION ALL of the three queries but only one will actually return data
    CREATE VIEW THREE_TABLE_EMP_VIEW AS
    select * from emp where 'EMP' = sys_context( 'VIEW_CTX', 'TABLE_NAME' )
    union all
    select * from emp1 where 'EMP1' = sys_context( 'VIEW_CTX', 'TABLE_NAME' )
    union all
    select * from emp2 where 'EMP2' =  sys_context( 'VIEW_CTX', 'TABLE_NAME' )
    -- first time - no data since context variable hasn't been set yet
    SELECT * FROM THREE_TABLE_EMP_VIEW
    -- get data from the EMP table
    exec set_view_flag( p_table_name => 'EMP' );
    SELECT * FROM THREE_TABLE_EMP_VIEW
    -- get data from the EMP2 table
    exec set_view_flag( p_table_name => 'EMP2');
    SELECT * FROM THREE_TABLE_EMP_VIEW
    For your use case you just have to call the context procedure whenever you want to switch tables. You can union all as many queries as you want and can even put WHERE clause conditions based on other filtering criteria if you want. I have used this approach with report views so that one view can be used to roll up report data different ways or for different regions, report periods (weekly, quarterly, etc). I usually use this in a stored procedure that returns a REF CURSOR to the client. The client requests a weekly report and provides a date, the procedure calculates the START/END date based on the one date provided and sets context variables that the view uses in the WHERE clause for filtering.
    For reporting it works great!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • CAN I PASS A TABLE NAME AS A VARIABLE IN THE FROM CLAUSE?

    For some reason, I am trying to use a variable name containing the actual table name in the from clause and it won't allow me. I keep getting the error saying I need to declare the variable I'm using eventhough I've used it in another statement that is not the FROM clause.
    Example
    SELECT count(col1), sum(col2)
    FROM v_table_name;
    v_table_name was declared as:
    v_tablename VARCHAR2(20);
    v_tablename := real_table_name;
    Is it not allowed to use variables in the FROM clause or am I missing something here?

    You can use the Forms "From Clause Query" as the datasource for the data block. Then you can change the QUERY_DATA_SOURCE_NAME using set_block_property, so you can use any SQL statement you like. Of course you must name/alias the columns in a consistent manner so that the number of database items on the block matches those being queried.

  • SELECT statement in FROM clause - syntax help

    Hi,
    I want to have a SELECT statement in the FROM clause. I get syntax error when doing this and since I am new to ABAP I need som help.
    I want to do the following, (and if anyone has any SELECT statement from their own system which you know there is no syntax error in please post it here so I can analyze the syntax):
    *I leave the INTO itab clause out, since I only want to demonstrate the functionality
    I am trying to get.
    <b>SELECT</b> tableOne~someField
    <b>FROM</b> tab <b>AS</b> tableOne (<b>SELECT</b> someField
                                         <b>FROM</b> tab
                                         <b>WHERE</b> someFiled > 1) <b>AS</b> tableTwo
    <b>WHERE</b> tableOnesomeField > tableTwosomeField
    like I said, the problem is that the select statement in the parenthesis in the from clause seems to be incorrect because I get "wrong expression" when trying to compile. Is this because I cannot have a select statement in the from clause or is it because of a minor syntax error, such as I forgot a dot, or some other sign?
    thanks and regards
    Baran

    sorry i am not enough familiar with sub queries but some error i can see which i will state here.
    1> you have to use sub queries i.e. select in ( ) after where clause because here you are fulfilling a where clause by another select statement.
    like this
    SELECT * FROM SFLIGHT
        INTO WA
        WHERE SEATSOCC = ( SELECT MAX( SEATSOCC ) FROM SFLIGHT ).
    2> you cannot specify field name without into clause either you have to use
    select *  or select f1 into tab-f1  like this...
    but if you are using select * without into you have to define
    tables : dbtab.
    selec * from dbtab. like that.
    regards
    shiba dutta

  • Can't get query to work.  table alias in subquery in FROM clause

    How can I rearrange this query to work?
    SELECT
                               TO_CHAR(dt.date_time, 'YYYY-MM-DD') start_date,
                                       (SELECT COUNT(*) FROM
                                            (SELECT DISTINCT a.non_asp, a.start_time, a.end_time
                                                  FROM appointments a
                      WHERE  a.start_time >= dt.date_time AND a.start_time < dt.date_time + 1
                                       ) num_overlap
                             FROM
                                  table(times_pkg.between_times(TO_DATE('2010-05-30'),
                                             TO_DATE('2010-07-03'), 60*24, 'Y')) dtbetween_times is a table function that returns times at given intervals.
    I am trying to get a count of distinct (non_asp, start_time, end_time) sets that fall on each day.
    However, it doesn't recognize dt.date_time in the FROM clause.

    Hi,
    A sub-query can be correlated only to its immediate parent. You're trying the correlate the SELECT DISTINCT sub-query to its grandparent.
    You can re-write the sub-query as a join, like this:
    SELECT  TO_CHAR(dt.date_time, 'YYYY-MM-DD') start_date,
         a.num_overlap
    FROM     table ( times_pkg.between_times ( TO_DATE('2010-05-30'),
                               TO_DATE('2010-07-03'),
                               60*24,
                               'Y'
               ) dt
    JOIN    (
           SELECT    start_time,
                    end_time,
                  COUNT (DISTINCT non_asp)     AS num_overlap
           FROM         appointments
         )  a         ON  a.start_time         >= dt.date_time
                  AND a.start_time         < dt.date_time + 1
    ;You could also eliminate the extra level between the SELECT DISTINCT sub-query and the main query by using SELECT (DISTINCT ...).

  • Exception: DBD, [Microsoft][ODBC Excel Driver] Syntax error in FROM clause.

    Dear experts,
    I'm trying to create an universe linked to an Excel File.
    I've created the ODBc connection and the DNS Data Source and inserted the table (table name RAC$) in the Universe. however, when I try to map each table field in the universe's Objects I'm getting this error message:
    "Exception: DBD, [ODBC Excel Driver] Syntax error in FROM clause.State:37000".
    I've tried to rename the table, inserting square brackects and also add new parameters to the universe («Transactional Available = "Yes"» and «Delimited Identifier = "Yes"») but still no solution to my problem.
    Any advice, tip or trick?
    Thank you. My best regards.
    Inês Santos

    Hi Ines,
    Thanks for sharing how you resolved this! I will bookmark this so that I can find it when I will likely need it!
    Bill
    Sorry I don't know how to make the accent circumflex! Or is that what you call it? On top of the e?
    Edited by: wavery on Jun 11, 2010 12:07 AM
    Edited by: wavery on Jun 11, 2010 12:09 AM

  • Error in FROM clause

    hi,
    ok i have a piece of code which looks like
    ResultSet rs = stmt.executeQuery("SELECT OrderDate, ProdNumber, Quantity, Price, OrderNumber FROM Order WHERE EmailAddress='" + email + "'");
    when i execute it... i get following error
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in FROM clause.
    i don't think there is any problem with syntax...
    thanx in advance

    Hey the escape character in java is \ you need to use that to escape the property of " for eg you will write like this ResultSet rs = stmt.executeQuery("SELECT OrderDate, ProdNumber, Quantity, Price, OrderNumber FROM Order WHERE EmailAddress= "\""+ email + "\"");
    try this and let me know if it works

  • Sequence of tables in from clause and sequence of "where clause" conditions

    Is Sequence of tables in "From Clause" and sequence of "where clause" conditions matters in 10g for performance?
    Edited by: user6763079 on Jun 1, 2011 3:33 AM

    user6763079 wrote:
    Is Sequence of tables in "From Clause" and sequence of "where clause" conditions matters in 10g for performance?In general it does not matter.
    It could matter if the Rule Based Optimizer (RBO) is used. However this RBO is only used if enforced by a hint or if no table statistics are collected. Starting from 10g the table statistics are automatically selected by a regular database job. So in general the CBO would be used.
    The CBO will consider different access paths. If the number of tables is low enough, then all possible combinations are considered and the order does not make any difference.
    Edited by: Sven W. on Jun 1, 2011 4:00 PM

  • Curious about this From clause in Oracle XE

    SQL view of query Builder gives the following:
    select     "EMPLOYEES"."EMPLOYEE_ID" as "EMPLOYEE_ID",
         "EMPLOYEES"."FIRST_NAME" as "FIRST_NAME",
         "EMPLOYEES"."LAST_NAME" as "LAST_NAME"
    from     "EMPLOYEES" "EMPLOYEES"
    Why does the from clause showing "EMPLOYEES" "EMPLOYEES"?
    In the SQL Commands of the SQL the folowing query
    select     "EMPLOYEES"."EMPLOYEE_ID" as "EMPLOYEE_ID",
         "EMPLOYEES"."FIRST_NAME" as "FIRST_NAME",
         "EMPLOYEES"."LAST_NAME" as "LAST_NAME"
    from     "EMPLOYEES
    gives the same result and so does
    select     "EMPLOYEES"."EMPLOYEE_ID" as "EMPLOYEE_ID",
         "EMPLOYEES"."FIRST_NAME" as "FIRST_NAME",
         "EMPLOYEES"."LAST_NAME" as "LAST_NAME"
    from     "EMPLOYEES" "EMPLOYEES"
    What is the significence of the second "Employees" in the FROM clause.

    Other interesting feature is the double quotes
    although the one above works as well.
    Why is this?Habit.
    Some developers come from environments that support mixed case identifiers (table and column names). These developers sometimes go out of their way to force Oracle to use mixed case identifiers, and that requires double quotes.
    So Oracle seems to have gotten into the habit of surrounding all identifiers (coming from generated code) with double quotes to keep these developers (who usually have other porting issues anyway) from having to trace those identifier issues.

  • CASE in the FROM clause ?

    Hello, I need to query a table which (unfortunately) its name is depended on the date. (Year, Month, and every 15 days (Fortnight FN)
    My tables is STAT_VEHICLES_YY_MM and if it refers to the fortnight report it becomes STAT_VEHICLES_YY_MM15
    For example this fortnight (15 of July report) will be STAT_VEHICLES_09_0815 and the 1st of this month report was on STAT_VEHICLES_09_08 table.
    My query so far is:
    ACCEPT YY prompt 'Please enter current year in YY format:'
    ACCEPT MM prompt 'Please enter current month in the MM format:'
    SELECT COUNT(*) "STAT VEH. NEW LIC."
    FROM STAT_VEHICLES_&YY._&MM
    WHERE NR=3;
    I tried using something like
    ACCEPT FN prompt 'Is this a fortnight report? (Y/N): '
    SELECT…
    FROM
    CASE
    WHEN &FN = Y THEN STAT_VEHICLES_&YY._&MM.15
    WHEN &FN = y THEN STAT_VEHICLES_&YY._&MM.15
    WHEN &FN = N THEN STAT_VEHICLES_&YY._&MM
    WHEN &FN = n THEN STAT_VEHICLES_&YY._&MM
    END
    WHERE…
    But I don’t think that CASE will work in the FROM clause
    My next though is OUTER JOIN and here is where I need your help people.
    Thank you

    Obviously this is extreemly poor design, and it should have been implemented by partitioning 1 table.
    In that case Oracle would have automatically choosen the right partition!!!
    What you can do is
    column table_name new_value tablename
    ACCEPT YY prompt 'Please enter current year in YY format:'
    ACCEPT MM prompt 'Please enter current month in the MM format:'
    select stat_vehicles_&YY._&MM table_name
    from dual;
    select count(*)
    from &_table_name
    where nr=3;
    You would need to use &_table_name everywhere.
    Hth
    Sybrand Bakker
    Senior Oracle DBA

  • Using from clause property

    i have written a query using joins inorder to get data from various tables.i have used FROM CLAUSE QUERY property and placed the quuery in the property pallate.now when Find button is pressed the data is not getting populated..please guide me in getting the data.

    Hi ,
    After creating your Data Block which is based on a FROM Query , start insearting the items into that block and map the Fields that would be returned from the Select statement to the items on your Data Block , thats all you need to do ,
    Regards,

  • Using FROM clause query in block

    I have a block using a FROM clause query instead of a table. I have two items in the block that correspond to the select statement. Here's the SQL statement I've entered:
    SELECT BEZEICHNUNG, ZEIT_TYP_NR
    FROM ZEIT_TYPE
    WHERE ZEIT_TYP_NR IN
    (SELECT ZEIT_TYP_NR
    FROM PROM_ZEIT_TYP
    WHERE PROM_TYP_NR = :GLOBAL.PROM_TYP_NR)
    When I run forms, it ADDS to my SQL statement!! Here's what it does:
    SELECT BEZEICHNUNG,ZEIT_TYP_NR
    FROM (SELECT BEZEICHNUNG, ZEIT_TYP_NR FROM ZEIT_TYPE) WHERE ZEIT_TYP_NR IN
    (SELECT ZEIT_TYP_NR
    FROM PROM_ZEIT_TYP
    WHERE PROM_TYP_NR = :1)
    can anyone tell me why it's adding this first line to my select statement??

    "a from clause query" is the rather strange name forms uses for what is generally known as in an in-line view.
    Your in-line view is being treated by forms the same way as it would a table, it sticks a SELECT, a list of columns determined from the database items in the block and a FROM on the beginning. If the user specifies query criteria in enter-query mode it will quite correctly apply the where clause to the outer select rather than to the in-line view.

  • Stupid question: whats wrong here? -- Syntax Error in FROM clause

    i keep getting the error: Syntax Error in FROM clause.
    here is the code:
    <%@ page import="java.sql.*" %>
    <HTML>
    <HEAD>
         <TITLE>User Application Area</TITLE>
    </HEAD>
    <BODY BGCOLOR="#FFFFFF" TEXT="#000000">
    <%
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:fypproject","","");
    Statement st = con.createStatement();
    String email = (String)session.getAttribute("email");
    String levelStatus = (String)session.getAttribute("levelStatus");
    String details = "SELECT PD.Forename, PD.Surname, L.Level_Name FROM PD Personal_Details AND LD Login_Details AND L Level WHERE PD.Email_Address = LD.Email_Address AND LD.Level_ID = L.Level_ID AND Level_ID = '" + levelStatus + "'";
    ResultSet rsDet = st.executeQuery(details);
    if(rsDet.next()) {
    String forename = rsDet.getString("Forename");
    String surname = rsDet.getString("Surname");
    String level_name = rsDet.getString("Level_Name");
    %>
    <DIV ALIGN="center"><H1>User Application Arena</H1></DIV>
    <BR>
    <H4>Welcome back <% out.println(forename + " " + surname); %> </H4>
    <BR>
    <%
    out.println(level_name);
    else {
    out.println("NOT FOUND ANYTHING");
    st.close();
    con.close();
    %>
    </BODY>
    </HTML>
    the strange thing is when i write a query that doesn't involve the 'Level' table it works fine.
    for example if i just want to display the forename and surname from 'Personal_Details' where the Email_Address = email it works fine...as soon as i involve the 'Level' table i get this error.
    i basically have 'Level_ID' in the 'Login_Details' table which is found out in the preceding jsp and passed through to this page and i can print out the Level_ID
    but....what i want to do is use this Level_ID and find the respective Level_Name in the Level table.
    my Level table looks like this:
    Level_ID Level_Name
    0 Pending
    1 Interview
    2 Rejection
    Thanks :o)

    Perhaps this is your issue ...
    The column Level_ID is in both the Login_Details and Level tables. Therefore, in your WHERE clause, you must specify a table alias for each reference to Level_ID
    WHERE PD.Email_Address = LD.Email_Address AND LD.Level_ID = L.Level_ID AND Level_ID = '" + levelStatus + "'";
    should be
    WHERE PD.Email_Address = LD.Email_Address AND LD.Level_ID = L.Level_ID AND L.Level_ID = '" + levelStatus + "'"; //ADDED "L." before Level_ID
    Level_ID would have been unique until you added the Level table.
    Good luck.
    -Mark

  • Syntax error in From clause from Access

    I am trying to migrate a database from Access 2000, and all of the tables except one migrate correctly. The one problem table gives me the following error message:
    Unable to migrate table data: NWQ_TANC.PARAMETERS; [Microsoft][ODBC Microsoft Access Driver] Syntax error in FROM clause.
    Does anyone know how to fix this? I have found the error in the help Appendix, but it just lists it as a QUERY type error, #3131, and gives no explanation or clues on how to fix it.
    Thanks, Jessica

    Hi Jessica
    Just wondering if you ever managed to find a solution to this problem, as I am getting a very similar error - only I don't just get it for one table, I get it for every single table in the database!
    Would be very interested to hear if you managed to sort it or not
    Cheers
    Ed

  • Error in FROM clause (MS Access)

    I'm getting an 'error executing a database query.' The query
    is a simple
    <cfquery name="myquery" datasource="#application.dsn#">
    SELECT *
    FROM #url.table#
    </cfquery>
    The debugging info i get is as follows:
    SELECT * FROM Order
    VENDORERRORCODE -3506
    SQLSTATE 42000
    It also states the error is in the FROM clause and only
    happens when url.table is Order, not the other table names. I know
    the order table exists because i get a nonexistent table name error
    when url table is a bogus table name. This implies that
    it knows the order table exists but says there's an error in
    the FROM clause. The query is successful on all the other tables in
    my db (MS access, i'm using the access driver without unicode). Any
    ideas?

    order is a reserved word...you'll need to escape it using
    brackets
    FROM [order]
    HTH
    Tim Carley
    www.recfusion.com
    [email protected]

Maybe you are looking for