SQL in Access 2013 syntax error - ms-access-2013

I've just recently started trying to learn SQL and I cannot seem to figure out my syntax error is. MS Access 2013 keeps telling me that there's an error after the NOT EXISTS query. All I am trying to do is display results from one table (table A or PILOT)that do not exist in another table (table B or FLIGHT). Here are my SQL statements (the lot)
SELECT A.LIC_NUM
FROM PILOT AS A
WHERE NOT EXISTS [
SELECT *
FROM FLIGHT AS B
WHERE A.LIC_NUM = B.FLIGHT_PILOT
];
It bugs me that something so simple could be causing this much of a problem. Any help would be greatly appreciated.

You are using bracket but you have to use parenthesis
SELECT A.LIC_NUM
FROM PILOT AS A
WHERE NOT EXISTS (
SELECT *
FROM FLIGHT AS B
WHERE A.LIC_NUM = B.FLIGHT_PILOT
);
Please "Mark as Answer" if a post has answered the question

Related

Can't get Oracle SQL Developer to display specific values from object table

I've started learning SQL and playing with Oracle SQL Developer v22. For some reason I'm not able to retrieve value from an object table by using SELECT VALUE(A). It only gives my user ID.object_name as in the below screenshot. Any tips why?
SELECT VALUE(A) FROM table A;
If I use SELECT * FROM table; all is fine.
SELECT * FROM table A;
I've tried printing using dmbs_output, same problem.
Tried with other object tables, same behaviour.
Please share your table DDL and DML for a more accurate answer, but setting this preference should do what you're looking for
'Display Struct Value in Grid'
I talk about that here
Disclaimer: I work for Oracle and am the product manager for SQL Developer.

How to add comment in Clickhouse SQL query

I met this strange thing and want to understand how you handle it.
I am using Monaco editor to write sql query and then using node clickhouse library to run the query, so, in the editor, user entered this:
-- Explain
select * from table 1
and the query sent to clickhouse is this:
-- Explain\nselect * from table 1
But when running this, I got error
:"SyntaxError: Unexpected number in JSON at position 2\n at pa...
Seemed the comment here is causing the error.
Can you tell me how to put comment into the query and send to clickhouse to run?
Have you already found the solution to your problem?
Otherwise I can advise you to use the "multi-line comments" as follows:
/* Explain */
SELECT *
FROM table1
It gets around the problem to achieve the desired result.

SELECT statement in SQL DEVELOPER

So I am new in SQL DEVELOPER tools and I have written a simple select statement like:
SELECT * FROM employee;
it worked fine but there was a yellow warning mark underneath SELECT and I clicked on that and my query changes into the following query:
SELECT "A1"."EMPLOYEE_ID" "EMPLOYEE_ID","A1"."FIRST_NAME" "FIRST_NAME","A1"."LAST_NAME" "LAST_NAME","A1"."SALARY" "SALARY", "A1"."DEPARTMENT_ID" "DEPARTMENT_ID","A1"."MANAGER_ID" "MANAGER_ID","A1"."HIRE_DATE" "HIRE_DATE"
FROM "INTRO_USER"."EMPLOYEE" "A1";
My Quest is what is the difference between these two queries? although their output is the same
The glob * has been expanded to all column of the table. The table name EMPLOYEE is aliased to A1 to make it shorter.
The feature you are seeing is called 'SQL Text Expansion,' and it's setup to allow you to see what your query would look like if you were working with one or more VIEWS.
For example, SELECT * FROM ALL_TABLES is quite complicated. This feature allows you to see what's actually involved when running that SQL.
https://www.thatjeffsmith.com/archive/2014/12/sql-developer-and-a-12c-magic-trick/
There is probably no change or expected delta in the performance or execution plan of the 2 versions of your query.

Oracle Functionality of Insert All Into Versus By Individual Column

I've gotten to one of those places where I've been toying with something for a little while trying to figure out why its not working and figured I would ask here. I am currently in the middle of making adjustments to a batch process that involves creating an external table A used for staging and then transferring the data from that table over to Table B for further processing.
There's a step in the batch that was there before to load all that data and it goes like this:
INSERT INTO TABLE B SELECT * FROM TABLE A
Upon running this statement in batch and outside of it in Oracle Developer I get the following error:
Run query ORA-00932: inconsistent datatypes: expected DATE got NUMBER
I went through my adjustments line by line and made sure I had the right data types. I also went over the data itself the best I could and from what I can tell it seems normal also. In an effort to find which individual field could have been having the error, I attempted to load data from Table A to Table B one column at a time...Doing this I received no errors which shocked me somewhat. If I use the SQL below and have all the fields listed out individually, the load of all the data works flawlessly. Can someone explain why this might be? Does the below function perform an internal Oracle working that the previous one does not?
insert into TABLE B (
COLUMN_ONE,
COLUMN_TWO,
COLUMN_THREE
.
.
.)
select
COLUMN_ONE,
COLUMN_TWO,
COLUMN_THREE
.
.
.
from TABLE A;
Well, if you posted description of tables A and B, we could see it ourselves. As it is now, we have to trust what you're saying, i.e. that everything matches (but Oracle disagrees), so I don't know what to say.
On the other hand, I've learnt that using
INSERT INTO TABLE B SELECT * FROM TABLE A
is a poor way of handling things (unless that's a quick & dirty testing). I try to always name all columns I'm working with, no matter how many of them are involved in that very operation. As you noticed, that seems to be working well for you too, so I'd suggest you to keep doing it.

How to recreate SAP queries in Oracle?

I need to recreate some SAP stored procedures in Oracle. I've been trying to find tutorials, similar questions, examples, etc about this but apparently no one had to do this before
What Oracle SQL query can be similar to this SAP query ?
SELECT * FROM A
INTO CORRESPONDING FIELDS OF TABLE B
FOR ALL ENTRIES IN C
WHERE a = C-a
AND x = y.
LOOP AT B INTO D.
D-b = E-b.
INSERT c FROM D.
IF SY-SUBRC <> 0.
WRITE: / 'error on insert', D-b, D-a.
ENDIF.
Any help will be appreciated, Thanks.
I recommend you to use transaction 'ST05' to trace your program. This tool will show details of the queries on the database including the exact SQL executed.
EDIT:
As a demonstration of the queries generated by SAP for Oracle let's execute this code and trace it with transaction 'ST05'. Remember to run 'ST05' before executing the program.
tables: mara.
data: it_mara type standard table of mara,
it_eina type standard table of eina.
select-options so_matnr for mara-matnr.
start-of-selection.
select matnr from mara into corresponding fields of table it_mara
up to 100 rows where matnr in so_matnr.
check sy-subrc eq 0.
select * from eina into table it_eina for all entries in it_mara
where matnr eq it_mara-matnr.
After execution check the output in transaction 'ST05':
If you want more details select an SQL statement in the screen and then click the button 'Explain'. You will see the following:
For better reference on transaction 'ST05' check this link.
Hope it helps.
The FOR ALL ENTRIES statement usually produces many queries which results are then grouped by UNION or UNION ALL.
Here is a really nice analysis for Microsoft SQL Server.
Because of the fact that UNION and UNION ALL are part of SQL standard I think it is implemented exactly the same for any other SQL database.
[EDIT]
As Mr Miranda stated it looks differently when it comes to Oracle database. I googled a bit and found this article where it is said that IN-LISTs are used which seems also to be plausible.

Resources