Truncate table sqlite

truncate table sqlite The TRUNCATE TABLE statement is used to remove all records from a table. SQLite does not have an explicit TRUNCATE TABLE command like other databases. Instead, it has added a TRUNCATE optimizer to the DELETE statement. To truncate a table in SQLite, you just need to execute a DELETE statement without a […]

Truncate table sqlite Read More

Sqlite3 get data from table c

sqlite3 get data from table c #include <stdio.h> #include <string> using std::string; #include <sstream> using std::stringstream; #include “sqlite3.h” bool find_employee(int _id) { bool found = false; sqlite3* db; sqlite3_stmt* stmt; stringstream ss; // create sql statement string // if _id is not 0, search for id, otherwise print all IDs // this can also be […]

Sqlite3 get data from table c Read More

Sql stored procedure

sql create stored procedure —————————————————————————————————- — MySQL (scroll down for Oracle) — example CREATE OR REPLACE PROCEDURE select_employees() BEGIN select * from employees limit 1000; END; — Reset the delimiter /* syntax: CREATE PROCEDURE <your-procedure-name>(<argument1><argument2>…<argumentn>) BEGIN <code-that-stored-procedure-executes>; END; */ —————————————————————————————————- — Oracle — EXAMPLE CREATE OR REPLACE PROCEDURE select_employees() BEGIN select * from employees limit […]

Sql stored procedure Read More

Sql server group by concatenate

sql server group by concatenate CREATE TABLE #YourTable ([ID] INT, [Name] CHAR(1), [Value] INT) INSERT INTO #YourTable ([ID],[Name],[Value]) VALUES (1,’A’,4) INSERT INTO #YourTable ([ID],[Name],[Value]) VALUES (1,’B’,8) INSERT INTO #YourTable ([ID],[Name],[Value]) VALUES (2,’C’,9) SELECT [ID], STUFF(( SELECT ‘, ‘ + [Name] + ‘:’ + CAST([Value] AS VARCHAR(MAX)) FROM #YourTable WHERE (ID = Results.ID) FOR XML PATH(”),TYPE).value(‘(./text())[1]’,’VARCHAR(MAX)’) […]

Sql server group by concatenate Read More

Sql not equal

sql not equal <> Not equal. Note: In some versions of SQL this operator may be written as != Example sql query: 1) Selecting groceries where price is not 20 SELECT * FROM Grocery WHERE Price <> 20; not equal operator sql <> Not Equal != Not Equal

Sql not equal Read More

Sql left characters

sql left characters — For Oracle only — syntax SUBSTR(<main-string>,1,<number-of-characters>) — example SUBSTR(‘Useless stuff’,1,10) — OUTPUT: Useless st — practical example SELECT SUBSTR(‘Useless stuff’,1,10) FROM DUAL;</number-of-characters></main-string>

Sql left characters Read More

Sql joins in python

SQL joins in python This was What I intended  ID Case NxtCase  1    A          2    C          3    E       This is my desired result  ID Case NxtCase  1    A        B  2    C        D  3 […]

Sql joins in python Read More

Sql group by sum

sql group by sum // Use SQL Group By clause after the Where clause // Any column in the select list must either be in the Group By clause // or part of an agregation statement, like the Sum() statement // Multiple columns can be included in the Group By Clause seperated by a comma […]

Sql group by sum Read More