What is SQL?
On the other hand, SQL (Structured Query Language) is the actual language used to perform operations on databases. These operations include the act of inserting data, updating it, deleting it, and so on.
SQL is a global standard for relational databases. Relational databases are ones that contain co-related, associative data.
To perform any operation on a table, we write what's called a query and execute it. A query is a set of instructions written in SQL. Like any other language, SQL has its own syntax and keywords.
Using SQL is the most efficient way to process data in datastore. You don’t have to write lengthy code just to perform simple operations. It just takes a query. The basic queries like inserting, deleting, and updating take no more than a single line of code. Many consider SQL to be an intuitive language, and almost every database management system (DBMS) supports it.
With this basic understanding of databases and SQL, let's move on to interview questions based on these concepts.
xxxxxxxxxxjoin table t ON r.RandomKey = t.UniqueKey-- THE BELOW IS SAMPLE SQLcreate table RandomKeys (RandomKey int)create table RandomKeysAttempt (RandomKey int)-- generate m random keys between 1 and ndeclare @cnt int = 0;while @cnt < mbegin insert RandomKeysAttempt select rand()*n + 1end;-- eliminate duplicatesinsert RandomKeys select distinct RandomKey from RandomKeysAttempt-- as long as we don't have enough, keep generating new keys,-- with luck (and m much less than n), this won't be necessarydeclare @NextAttempt = rand()*n + 1;while count(RandomKeys) < mbegin if not exists (select * from RandomKeys where RandomKey = NextAttempt)begin insert RandomKeys select NextAttemptend;end;-- get our random rowsselect *from RandomKeys r

