Skip to content

Examples

Pamblam edited this page Dec 11, 2016 · 2 revisions

CREATE Queries

Each of the following queries are identical

jSQL.query("Create table if not exists oTable "+
	"(name varchar(50,5), age int, created date, greet function, favorite_hat hat)").execute();
jSQL.createTable({oTable: {
	name: {type:"VARCHAR": args:[50,5]},
	age: {type:"INT"},
	created: {type:"DATE"},
	greet: {type:"FUNCTION"},
	favorite_hat: {type:"HAT"}
}}).ifNotExists().execute(); 

SELECT Queries

Each of the following queries are identical

jSQL.query('SELECT * FROM table WHERE column1 = "value"').execute();
jSQL.query('SELECT * FROM table WHERE column1 = ?').execute(['value']);
jSQL.select('*').from('table').where('column1').equals("value").execute(); 

UPDATE Queries

Each of the following queries are identical

jSQL.query('UPDATE table SET column = value').execute();
jSQL.query('UPDATE table SET column = ?').execute(['value']);
jSQL.update('table').set({column: 'value'}).execute();
jSQL.update('table').set({column: '?'}).execute(['value']);

DELETE Queries

Each of the following queries are identical

jSQL.query('DELETE FROM table WHERE column = value').execute();
jSQL.query('DELETE FROM table WHERE column = ?').execute(['value']);
jSQL.deleteFrom('table').where('column').equals('value').execute();
jSQL.deleteFrom('table').where('column').equals('?').execute(['value']);

DROP Queries

Each of the following queries are identical

jSQL.query('DROP TABLE `Users`').execute();
jSQL.dropTable('Users').execute();

Clone this wiki locally