Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do the dots mean in this SQL query?

Tags:

mysql

I'm new to MySQL. Can anyone describe lines below which I get theme from the demo of the jqgrid, what is the meaning of a.id? What is the meaning of these dots?

$SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id ORDER BY $sidx $sord LIMIT $start , $limit";

You can find the example here: http://trirand.com/blog/jqgrid/jqgrid.html in the advanced>Multi select

like image 838
Reza M.A Avatar asked Jul 14 '12 13:07

Reza M.A


People also ask

What do dots mean in SQL?

Dot notation (sometimes called the membership operator ) qualifies an SQL identifier with another SQL identifier of which it is a component. You separate the identifiers with the period (.) symbol. Column projections qualify a column name with the following SQL identifiers: Table name: table_name .

What are two dots in SQL query?

The two dots indicate that the schema name is not specified. The PUBLIC default schema is always referenced. Note that this notational format is provided mostly for compatibility with other systems, such as Microsoft SQL Server and IBM Netezza. Using this notation in new queries is discouraged.

What does an asterisk (*) mean in your code in SQL?

The asterisk or star symbol ( * ) means all columns. The semi-colon ( ; ) terminates the statement like a period in sentence or question mark in a question.

What is '%' in SQL query?

The SQL LIKE Operator The percent sign (%) represents zero, one, or multiple characters. The underscore sign (_) represents one, single character.


1 Answers

You've asked several questions here. To address the dots:

In the FROM clause, a is used as an alias for the invheader table. This means you can reference that table by the short alias a instead of the full table name.

Therefore, a.id refers the the id column of the invheader table.

It is generally considered bad practice to simply give your tables the aliases a, b, c, etc. and I would recommend you use something more useful.

I suggest you read some basic MySQL tutorials as this is a fundamental principal.

like image 65
Sir Crispalot Avatar answered Oct 20 '22 17:10

Sir Crispalot