Sql query for login with email or username

sql query for login with email or username if($_POST[‘username’] != ” && $_POST[‘password’] != ”){$name = $_POST[‘username’];$pass = md5($_POST[‘password’]);$check_email = Is_email($name);if($check_email){// email & password combination$query = mysql_query(“SELECT * FROM `users` WHERE `email` = ‘$name’ AND `password` = ‘$pass'”);} else {// username & password combination$query = mysql_query(“SELECT * FROM `users` WHERE `username` = ‘$name’ AND `password` […]

Sql query for login with email or username Read More

Sql join one to many

sql join one to many SELECT * FROM Parent P INNER JOIN Child C ON C.ParentId = P.ParentId sql join one to many SELECT P.Name , P.Address , SUM(C.Amount) FROM Parent P INNER JOIN Child C ON C.ParentId = P.ParentId GROUP BY P.Name , P.Address

Sql join one to many Read More

Sql find second highest salary employee

sql find second highest salary employee /* sql 2nd highest salary employee */ select sal, ename from emp where sal = ( select max(sal) from emp where sal < (select max(sal) from emp) ) ———————————————– option 2 select * from ( select ename, sal, dense_rank() over(order by sal desc) rank from emp ) where rank […]

Sql find second highest salary employee Read More

Sql create a table

SQL CREATE A TABLE CREATE TABLE TestTable AS SELECT customername, contactname FROM customers; SQL CREATE A TABLE CREATE TABLE new_table_name AS     SELECT column1, column2,…     FROM existing_table_name     WHERE ….; create table sql # Simple table describing a vehicle CREATE TABLE vehicle( # vehicleId: Unique ID for Primary Key. # This is how we […]

Sql create a table Read More

Sql count having

sql count having SELECT COUNT( * ) FROM agents HAVING COUNT(*)>1; –count is greater than 1 SQL HAVING SELECT COUNT(CustomerID), Country FROM Customers GROUP BY Country HAVING COUNT(CustomerID) > 5;

Sql count having Read More