Questions tagged [table-alias]

65 questions
3
votes
2 answers

whats is the importance of table alias in sql join query?

I wrote a sql join query in oracle with two table. While writing query I did not use any table alias to refer column in select clause. Now this was possible because the selected columns were having different names in both the tables. So the question…
hanumant
  • 1,091
  • 4
  • 15
  • 27
3
votes
5 answers

sql select's using mysql query browser

I am wondering why when I use MySQL Query Browser and double click table names the sql statements look like this: SELECT * FROM database.table t; where t = the first letter of the table... What is the purpose of this letter? I am just curious
Richard
  • 15,152
  • 31
  • 85
  • 111
3
votes
2 answers

How to identify fields from different tables with the same name in a JOIN query result?

I'm running a query in MYSQL using LEFT JOIN to get users and their user groups. Both tables have columns named id. My result is being returned in an array (PHP) so that I have one array with all field data, but also only one array["id"]. Here's my…
Jürgen
  • 31
  • 1
3
votes
1 answer

Code igniter prepending db prefix in table aliases

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 =…
Jatin Dhoot
  • 4,294
  • 9
  • 39
  • 59
2
votes
3 answers

Can Oracle allow Permanent Alias for a table?

I was given an oracle dump file for an existing system. The dump file contained the table PARTS but when I look on the queries being done by the code. It uses mostly M_PARTS and just on one occasion, it uses PARTS. Does oracle allow multiple name on…
Nap
  • 8,096
  • 13
  • 74
  • 117
2
votes
8 answers

Opinions: SQL Statements, do you use table aliases?

One of the guys I work with has the following to say about using SQL aliases, and he just posted the following on reddit. What do you guys think, to alias or not to alias? .... So I've always been the odd man out of my with my dev team about how…
jameswfoster
  • 1
  • 1
  • 4
2
votes
2 answers

ORA - 00933 confusion with inner join and "as"

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…
1
vote
1 answer

Table aliases and the query optimiser

From a comment on https://stackoverflow.com/a/11064/247702 You save the query planner from needing to figure that out by using either Answer.Text or a.Text. It doesn't matter whether you use the table name or the alias, but qualifying the field…
user247702
  • 23,641
  • 15
  • 110
  • 157
1
vote
0 answers

How to get activerecord table aliases

How can I retrieve the alias that active_record generates? I would like to create a method table_alias_of that takes 3 arguments The model where the query is run from The includes hash Path of associations To address associations in the conditions…
Tom Maeckelberghe
  • 1,969
  • 3
  • 21
  • 24
1
vote
1 answer

The table is ambiguous

I am trying to create an update-Command in Microsoft SQL Server. The error is the table "field" is ambiguous. In the table "Field", I have user-specific Content (like First Name, Mailadress, Phone-Number). Every Field is on a separate Row, with a…
Gomoli
  • 27
  • 1
1
vote
2 answers

How to filter records having only rank=1 in oracle without using WITH block

Created a sample table and tried filtering records having rank 1 , but its failing Error ORA-00933: SQL command not properly ended 00933. 00000 - "SQL command not properly ended" *Cause: *Action: Error at Line: 30 Column: 3 CREATE TABLE exam_result…
1
vote
4 answers

How does this dot notation within SQL work?

I'm working with some SQL and trying to understand what is going on. Within the select there are what seem like variables s.id s.status with last_transactions as ( select s.id as station_id, s.status as…
Falko
  • 995
  • 11
  • 21
1
vote
2 answers

Every derived table must have its own alias - even though i have alias for every table

My command worked and when I tried inserting it again, I keep getting this error: Every derived table must have its own alias.. This is my command: SELECT s1.* FROM subpages AS s1 INNER JOIN ( SELECT s2.* FROM subsubpages AS s2 ) ON…
Ilona
  • 101
  • 9
1
vote
1 answer

subquery in FROM must have an alias POSTGIS

I am trying using the following query on a POSTGIS (Postgres) Database. The original question: https://gis.stackexchange.com/questions/313252/postgis-sql-query-filter-by-bounding-box SELECT row_to_json(fc) FROM ( SELECT 'FeatureCollection' As…
niaR
  • 107
  • 1
  • 9
1
vote
2 answers

ORACLE sql error - ORA-00933 - executing join operation - DBeaver

I'm trying to execute the next: SELECT l.id AS id FROM s.process AS l JOIN s.item AS r ON l.id = r.id; But I'm getting: Query execution failed Reason: SQL Error [933] [42000]: ORA-00933: SQL command not properly ended Using: DBeaver ojdbc7.jar…
Roni Koren Kurtberg
  • 495
  • 1
  • 8
  • 18