table-alias

Is there a way to give a subquery an alias in Oracle 11g SQL?

房东的猫 提交于 2021-01-21 00:00:08
问题 Is there a way to give a subquery in Oracle 11g an alias like: select * from (select client_ref_id, request from some_table where message_type = 1) abc, (select client_ref_id, response from some_table where message_type = 2) defg where abc.client_ref_id = def.client_ref_id; Otherwise is there a way to join the two subqueries based on the client_ref_id. I realize there is a self join, but on the database I am running on a self join can take up to 5 min to complete (there is some extra logic in

Is there a way to give a subquery an alias in Oracle 11g SQL?

我怕爱的太早我们不能终老 提交于 2021-01-20 23:54:35
问题 Is there a way to give a subquery in Oracle 11g an alias like: select * from (select client_ref_id, request from some_table where message_type = 1) abc, (select client_ref_id, response from some_table where message_type = 2) defg where abc.client_ref_id = def.client_ref_id; Otherwise is there a way to join the two subqueries based on the client_ref_id. I realize there is a self join, but on the database I am running on a self join can take up to 5 min to complete (there is some extra logic in

Update SQL with Aliased tables still returns “table is ambiguous” error

筅森魡賤 提交于 2020-12-31 04:38:36
问题 I am trying to run the below update but running into the "table is ambiguous" error. UPDATE dbo.cg SET cg.column = gId.ID FROM dbo.a INNER JOIN dbo.cg as cId ON cId.[a] = dbo.a.[c] INNER JOIN dbo.cg as gId ON gId.[a] = dbo.a.[b]; The table dbo.a contains data to update a value in cg based on a relationship to same table against a value in a different column. It is a self-referencing hierarchy. As you can see, everything is aliased so I am a bit confused why this won't run. Many thanks in

How can I give an alias to a table in Oracle?

痴心易碎 提交于 2019-12-17 17:12:15
问题 Why can't I give an alias to a table in Oracle DB? I tried to write a statement like this one: select count(id) from users as usr where usr.dept = "SVC"; But Oracle threw me an error. I don't remember having problem when I use something like this in MySQL. How can I give an alias to a table in Oracle? 回答1: Oracle doesn't allow as for table aliases, only column aliases. So do: select count(id) from users usr where usr.dept = 'SVC'; 来源: https://stackoverflow.com/questions/22161802/how-can-i

ORA - 00933 confusion with inner join and “as”

↘锁芯ラ 提交于 2019-12-17 14:56:48
问题 I have this query of getting data from two tables using an inner join , but I get the error SQL command not properly ended with an asterix under "as": select P.carrier_id, O.order_id, O.aircraft_id, O.quantity from orderline AS O inner join purchaseorder AS P on O.order_id = P.carrier_id; the error: from orderline AS O ( with an asterix under AS) Error at line 2 Ora-00933: SQL command not properly ended. In regards to this I thought that AS wouldn't be an issue as it's just referencing an

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

Deadly 提交于 2019-12-11 18:16:22
问题 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' 回答1: As @Yosi pointed out. The term I was looking for was table alias . 来源: https://stackoverflow.com/questions/26037481/what-is-the-correct-term-for-labeling-tables-in-a-query

Code igniter prepending db prefix in table aliases

落爺英雄遲暮 提交于 2019-12-10 10:46:25
问题 I have configured code igniter to use db prefix. At all other places it is working as expected but while creating table aliases it is prepending db prefix. Code is as under:- $this->db->from('table_a'); $this->db->join('table_b', 'table_a.id = table_b.a_id', 'left'); ----- $this->db->join('table_b as tablebAlias', 'table_c.id = tablebAlias.a_id', 'left'); Assuming my dbprefix is set to value 'foo'. Final query which is getting executed is as under:- Select * From foo_table_a left join foo

When is it required to give a table name an alias in SQL?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-07 02:15:56
问题 I noticed when doing a query with multiple JOINs that my query didn't work unless I gave one of the table names an alias. Here's a simple example to explain the point: This doesn't work: SELECT subject from items join purchases on items.folder_id=purchases.item_id join purchases on items.date=purchases.purchase_date group by folder_id This does : SELECT subject from items join purchases on items.folder_id=purchases.item_id join purchases as p on items.date=p.purchase_date group by folder_id

Code igniter prepending db prefix in table aliases

守給你的承諾、 提交于 2019-12-06 09:47:42
I have configured code igniter to use db prefix. At all other places it is working as expected but while creating table aliases it is prepending db prefix. Code is as under:- $this->db->from('table_a'); $this->db->join('table_b', 'table_a.id = table_b.a_id', 'left'); ----- $this->db->join('table_b as tablebAlias', 'table_c.id = tablebAlias.a_id', 'left'); Assuming my dbprefix is set to value 'foo'. Final query which is getting executed is as under:- Select * From foo_table_a left join foo_table_b on foo_table_a.id = foo_table_b.a_id --- left join foo_table_b as tablebAlias on foo_table_c.id =

When is it required to give a table name an alias in SQL?

十年热恋 提交于 2019-12-05 06:01:58
I noticed when doing a query with multiple JOINs that my query didn't work unless I gave one of the table names an alias. Here's a simple example to explain the point: This doesn't work: SELECT subject from items join purchases on items.folder_id=purchases.item_id join purchases on items.date=purchases.purchase_date group by folder_id This does : SELECT subject from items join purchases on items.folder_id=purchases.item_id join purchases as p on items.date=p.purchase_date group by folder_id Can someone explain this? You are using the same table Purchases twice in the query. You need to