Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does a colon (':') mean in SQL syntax? [duplicate]

Possible Duplicate:
What does the colon sign “:” do in a SQL query?

Simple SQL question: What does : stand for?

For example:

SELECT * FROM myTable
WHERE Employee_column = :P_EmplId;

The : isn't exactly easy to google when you don't know what this is called. Even searching here didn't help. I'm using Oracle 11g if that makes any difference.

like image 737
Gunnar Avatar asked Jun 26 '12 14:06

Gunnar


People also ask

What does a double colon mean in SQL?

Thanks for your question. The double colon represents a scope qualifier. In this instance, users are able to GRANT permission to objects like SCHEMA, LOGIN, ect. The double colon tells SQL Server that SCHEMA is the class.

What Does a colon mean in an SQL statement?

The colon (:) is used to select "slices" from arrays. (See Section 5.12.) In certain SQL dialects (such as Embedded SQL), the colon is used to prefix variable names. The asterisk (*) has a special meaning when used in the SELECT command or with the COUNT aggregate function.

Why do we use :: in SQL?

In addition to using cast, you can use :: to cast a value to a specific type.

How do you insert a colon in SQL query?

CREATE TEMP FUNCTION InsertColons(s STRING) AS ( CONCAT(SUBSTR(s, 1, 2), ':', SUBSTR(s, 3, 2), ':', SUBSTR(s, 5, 2)) ); SELECT s, InsertColons(s) AS result FROM ( SELECT '123456' AS s UNION ALL SELECT '170519' );


2 Answers

It is a bind variable:

A placeholder in a SQL statement that must be replaced with a valid value or value address for the statement to execute successfully. By using bind variables, you can write a SQL statement that accepts inputs or parameters at run time. The following example shows a query that uses v_empid as a bind variable:

like image 107
Taryn Avatar answered Sep 23 '22 14:09

Taryn


Most likely you took the query from a template. It is meant to be processed with php's MDB2 sql framework. The ":" (colon) signals a placeholder in the statement, meant to be replaced when the query is executed.

like image 31
arkascha Avatar answered Sep 20 '22 14:09

arkascha