Syntax of I/U/D

This section discusses the syntax for I/U/D statements.

Syntax of INSERT

The YQL INSERT statement has the following syntax:

INSERT INTO (table) (list of comma separated field names) VALUES (list of comma separated values)

The INSERT INTO keywords marks the start of an INSERT statement.

The table is either the YQL pre-defined or Open Data Table that represents a data source.

Following the table name is a list of field names indicating the table columns where YQL inserts a new row of data.

The VALUES clause indicates the data inserted into those columns. String values are enclosed in quotes.

In YQL, statement keywords such as SELECT and WHERE are case-insensitive. Table and field names are case sensitive. In string comparisons, the values are case sensitive. String literals must be enclosed in quotes; either double or single quotes are allowed.

Syntax of UPDATE

The YQL UPDATE statement has the following syntax:

UPDATE (table) SET field=value WHERE filter

The UPDATE keyword marks the start of an UPDATE statement. This is followed by the table name.

The table is either the YQL pre-defined or Open Data Table that represents a data source.

The SET clause is the part of the statement in which we pass new data to the update binding in the Open Data Table.

The WHERE clause indicates which data should be updated. Only remote filters can be present in the WHERE clause of an UPDATE statement.

The following example shows how the UPDATE statement syntax can look for updates to your status on Yahoo Profiles:

UPDATE social.profile.status SET status="Using YQL UPDATE" WHERE guid=me

Try this example in the YQL console

In the above example, status and guid are all bindings within the inputs element, which is nested within an update element. The status is a value element, since this is data that is updating a value using the Open Data Table. The guid binding is simply a key element, as it is a required "key" that determines ownership of this status.

Syntax of DELETE

The YQL DELETE statement has the following syntax:

DELETE FROM [table] WHERE filter

The DELETE keyword marks the start of a DELETE statement.

The table is either the YQL pre-defined or Open Data Table that represents a data source.

This is immediately followed by a remote filter that determines what table rows to remove.

The following example deletes a particular Yahoo update:

DELETE FROM social.updates WHERE guid="me" and suid="12345" and source="agg.bebo"

In the example above, the remote filters are the SUIDof the update followed by the guid of the Yahoo user and the source of the update.

Table of Contents