Questions tagged [table-alias]

65 questions
0
votes
1 answer

Why do I get an Error when I try to rename a table after FROM?

When I simply try to retrieve all of the rows in my table EMPLOYEE like this: SELECT * FROM EMPLOYEE AS emp; I get the following error: ORA-00933: SQL command not properly ended 00933. 00000 - "SQL command not properly ended" *Cause: *Action:…
Camonophy
  • 85
  • 4
0
votes
1 answer

how do I find median in sql (code question)

I find answers below: Select round(S.LAT_N,4) mediam from station S where (select count(Lat_N) from station where Lat_N < S.LAT_N ) = (select count(Lat_N) from station where Lat_N > S.LAT_N) I'm confused at where S come from??
melody
  • 1
  • 1
0
votes
1 answer

Query with join from MSSQL to Oracle

I have this query which runs on MsSQL: select BL.ID from O_USERS_BATCH as UB join O_BATCH_LOCK as BL on UB.INSTANCE_ID = BL.ID order by BL.ID How do I convert it to work with Oracle data base type?
Tal Angel
  • 1,301
  • 3
  • 29
  • 63
0
votes
0 answers

Is there any performance slowdown while using custom table alias instead of direct table name with columns in sql select command?

I am working on project with huge data and usage. Many procedures are being used with multiple joined SQL Select queries. My friend told me that using column names with table name is much better in respect to performance instead using column with…
user1482852
  • 94
  • 4
  • 11
0
votes
1 answer

getting error in oracle 009933 sql command not properly ended

here is my query by I didn't understand why it is not working. select o.MFR, o.PRODUCT, c.company, p.PRICE from ORDERS AS o inner join customers AS c on c.CUST_NUM = o.CUST inner join PRODUCTS AS p On p.MFR_ID = o.MFR where…
Sayed Mohd Ali
  • 2,156
  • 3
  • 12
  • 28
0
votes
1 answer

What is wrong with my oracle select query below?

Why my first select query shows error at 'AS' when the second one is ok? - oracle sql - error message: SQL command not properly ended
Shahril
  • 105
  • 1
  • 1
  • 9
0
votes
1 answer

Using Alias in query resulting in "command not properly ended"

I tried this: SELECT * FROM (SELECT * , ROW_NUMBER() OVER (ORDER BY vernum DESC, defvern DESC) AS RowNumber FROM MyTable INNER JOIN AnotherTable ON MyTable.id = AnotherTable.dataid WHERE MyTable.defid = 123456…
Batman
  • 5,563
  • 18
  • 79
  • 155
0
votes
1 answer

referencing table names (not aliases) in hints

I'm using eclipse link as JPA implementation. I have a named Query like this: @NamedQuery(name = "QueryName", query = "SELECT c FROM Customer c, AccountingUnit au where c.contract.state = :state AND ...") The resulting SQL query will…
EasterBunnyBugSmasher
  • 1,507
  • 2
  • 15
  • 34
0
votes
1 answer

What is the correct term for labeling tables in a query?

I'm trying to figure out the correct name for table labeling. SELECT var1, var2 FROM myTable TableRef The label I'm referring to is the variable TableRef, which can be referenced from a WHERE clause like follows: WHERE TableRef.var1 = 'someValue'
Jack Zach Tibbles
  • 800
  • 1
  • 11
  • 27
0
votes
2 answers

Correct sql query to return null when optional FK row doesn't exists for PK row (1 to none/many)

What is the correct way to write this query for mysql (this one seems to work, but seems idiotic) (191 is hard code for a variable) select t1.item_id, t1.item_name, t1.item_desc, t.quantity, t.price from (select * from items i where i.item_id =…
0
votes
3 answers

Does Squirrel SQL or Oracle have a way to alias table names in queries?

I'm using Squirrel SQL with Oracle. I often have to write quick queries for tables with longish names. It would be nice if I could give aliases to them and write queries like "select * from ft where n='blah'" instead of "select * from…
HappyEngineer
  • 4,017
  • 9
  • 46
  • 60
0
votes
0 answers

Use table alias which does equal the name of the aliased table?

Is it 'SQL standard save' to use table alias names which do equal their table names? Example: I have a table aaa: id -- 1 2 3 In MYSQL I run a query: select aaa.* from aaa aaa,aaa bbb which results in: id -- 1 2 3 1 2 3 1 2 3 So it seems, that…
Quicker
  • 1,247
  • 8
  • 16
0
votes
1 answer

Error message: Not unique table/alias MySQL

I am trying to insert sap_id from butikkdata2 into energy_stage_ext2 using a left join on male_id. This is my query: insert into energi_stage_ext2 ( maale_id, maale_date, kwh_t, lev_id, konsept, name, slag, sap_id…
Alexander
  • 624
  • 2
  • 7
  • 18
0
votes
1 answer

Confused about SQL Server trigger that does an UPDATE (strange UPDATE statement format)

The crux of my question is the following style of UPDATE statement in a trigger: update ActualTableName set X=Y from inserted I would have thought that this is a syntax error... the table "ActualTableName" does not appear in the "from"…
user505765
  • 529
  • 1
  • 8
  • 15
0
votes
1 answer

Self-join: SQL parse error on table alias

Using a simple self join to list employees' managers: CREATE VIEW AS SELECT e1.EMP_ID EmployeeId, e1.FNAME EmployeeName, e1.MANAGER ManagerName FROM EMPLOYEE e1 LEFT JOIN EMPLOYEE e2 ON e1.MANAGER = e2.EMP_ID Where the…
Stumbler
  • 2,056
  • 7
  • 35
  • 61