Thursday, September 1, 2022

SQL Cheatsheet - SELECT FROM WHERE clauses with examples

SQL Cheat sheet for beginners, SELECT clause, FROM clause, WHERE clause explained with examples.


 SELECT ... FROM ... WHERE clauses in SQL - Cheat sheet

Querying data using SELECT…FROM...WHERE clauses in SQL




To view required data from one or more tables.



SELECT parameters FROM tablename;


Parameters for SELECT:

*, list of attributes, functions, arithmetic operations are the parameters for the command (clause) SELECT.









Parameters examples for SELECT clause


SELECT * FROM student;

Result: Displays all columns of all records of student table.

List of attributes:

SELECT name, phone FROM student;

Result: Displays only name and phone of all students;


SELECT MAX(salary) FROM employee;

Result: Displays the maximum of all salary values stored in employee table.


SELECT Basic + HRA FROM employee;

Result: Displays the sum of the values stored in Basic and HRA columns (attributes) of all employee records.



To specify the name of the table/view from which we want to view the data.



SELECT parameters FROM tablename;

Parameters for FROM:

Table name or table names separated with comma.



Parameters examples for FROM clause

Single table:

SELECT * FROM employee;

Result: Displays all records from employee table.

Multiple tables:

SELECT * FROM employee, dept;

Result: It is a special case. It performs join. Displays columns of tables, employee and dept with every record of table employee combined with every record of dept.


To specify one or more conditions to filter the data to view/get required data only.



SELECT parameters FROM tablename WHERE condition;


Parameters for WHERE:

WHERE clause accepts the conditions (predicates) of the following format;

Attribute_name OP value;

Attribute_name OP attribute_name;

Here, OP refers to OPERATOR that can be one of =, <>, >, <, >=, and <=


More conditions can be mentioned in WHERE clause. In that case, the conditions should be connected using logical connectives AND, OR, NOT.

Parameter examples for WHERE clause

attribute_name OP value:

SELECT * FROM employee WHERE gender = ‘male’;

Result: Displays all records of employee who are MALE.


SELECT * FROM employee WHERE salary > 10000;

Result: Displays all records of employees who earn more than 10000.


SELECT name, age FROM employee WHERE salary = 25000;

Result: Displays only name and ages of all employees who earn 25000.

attribute_name OP attribute_name:

SELECT * FROM employee, dept WHERE emp_dno = dept_dno;





What are the parameters for SELECT clause?

Can we perform arithmetic calculations using SELECT clause in SQL?

How to filter the data in a table using WHERE clause?

Can we use more than one condition in WHERE clause?

How do you find cars that are sold for fifty thousand dollars or more?

Where to specify the condition like the watches that are costlier than Omega watches? 

Blogger Widgets

Monday, August 15, 2022

Natural Language Processing Multiple Choices Questions - HMM is a generative model

Multiple choices questions in NLP, Natural Language Processing solved MCQ, HMM is a generative model, Why HMM is referred as generative model?

Natural Language Processing MCQ - Hidden Markov Model (HMM) is a generative model

< Previous                      

                     Next >


1. A Hidden Markov Model (HMM) is a _____ which means that the model is specified by ______.

a) Discriminative model, P(X, Y)

b) Discriminative model, P(Y|X)

c) Generative model, P(X, Y)

d) Generative model, P(Y|X)


Answer: (c) Generative model, P(X, Y)

Hidden Markov Model (HMM) is a generative model. Generative models capture the joint probability p(X, Y).

Generative models calculate the conditional probability P(y|x) using the joint probability as follows;

P(y|x) = P(x,y) / P(x) = joint probability / prior probability of x

A generative model includes the distribution of the data itself, and tells you how likely a given example is. For example, models that predict the next word in a sequence are typically generative models because they can assign a probability to a sequence of words.

Discriminative models, in contrast, use no knowledge about the probability distributions that underlie a data set. They directly calculate the conditional probability, p(y|x), for a data set. They focus on discriminating between classes, as their name suggests, by analyzing the data to calculate decision boundaries between classes.


< Previous                      

                     Next >

Related links:

Top interview questions in NLP

NLP quiz questions with answers explained

Why HMM is a generative machine learning model?

Why HMM is not a discriminative model?

What is the difference between generative and discriminative models?

NLP Solved MCQ, Natural language processing solved mcq, language model solved mcq, perplexity solved mcq, nlp solved exercises

Featured Content

Multiple choice questions in Natural Language Processing Home

MCQ in Natural Language Processing, Quiz questions with answers in NLP, Top interview questions in NLP with answers Multiple Choice Que...

All time most popular contents

data recovery