June 7th, 2010 by admin
No comments »
My name is latif Khan. I am an IT Professional (Programmer, Developer, Analysit, Designer).
About my Education:
Msc Computer Science (Quaid-i-Azam University Islamabad pakistan)
MS Mobile Computing (University of Bedfordshire UK)
On this website you will find different programming and database tutorials .
August 17th, 2011 by admin
No comments »
This function convert first letter of a string to uppercase and the rest of the string will be in lowercase.
UPDATE table_name SET field_name = CONCAT(UPPER(LEFT(field_name, 1)), LOWER(SUBSTRING(field_name, 2)))
Cheap international calls
March 28th, 2011 by admin
No comments »
update column1 of table1 from column1 of table2 on the basis of both tables ids.
UPDATE table1
SET column1 = table2.column1
FROM table1 , table2
WHERE table1.column_id = table2.column_id
March 15th, 2011 by admin
No comments »
delete X1 from TableName X1, TableName X2
where X1.DupColumn = X2.DupColumn and X1.id > X2.id
December 1st, 2010 by admin
No comments »
Linux – 2.0
1. Create directory:
mkdir dir1
2. Remove empty directory:
rmdir dir1
September 30th, 2010 by admin
No comments »
A relational database consists a set of relations , attributes each attribute being identified by its name. Relational database is done to save maintenance cost, efficiency , save space (disk space)
More accurately, the relational model is based on predicate logic and set theory. You have sets of statements of fact, and the underlying system can determine new sets of facts from those. For efficiency, you have to organize those facts into groups that share the same structure (names and associated type domains), and in practice your ability to draw conclusions is limited by the system’s command language (SQL poorly implements predicate logic and set theory; and the database doesn’t do much of your thinking for you). The real power comes from your complete control over determining new facts. All relationships between facts are explicit in the database, and the command language can use and manipulate them. The mathematics behind the model make this manipulation feasible.
August 13th, 2010 by admin
No comments »
SELECT * from
FROM customers
INTO OUTFILE '/foldername/customers.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
August 12th, 2010 by admin
No comments »
this will return last inserted id in a table by a database connection used.
mysql_query($mysql_insert_query, $db_connection);
$last_inserted_Id = mysql_insert_id($db_connection);
July 26th, 2010 by admin
No comments »
Case in sql Select
Case can be used in different ways. In this example it is used as to mask the actual value of column.
SELECT product_id , 'Special Offer' = CASE
WHEN special_price < normal_price THEN 'Product on Special Offer'
ELSE 'Normal Price'
END
FROM Products
June 17th, 2010 by admin
No comments »
This query will select a random date time in the past 60 days
select cast( cast(getdate() as int) -60 * rand ( cast( cast(newid() as binary(8)) as int ) ) as DATETIME )
June 8th, 2010 by admin
No comments »
many of the programmers use nested loop to display two levels of category. which is not an efficient way. we can fetch all the data in one call, and then display it using some logic.
SELECT t1.cat_id , t1.cat_name AS main_cat_name , t2.cat_id as sub_catid, t2.cat_name as sub_cat_name FROM Categories AS t1 LEFT JOIN Categories AS t2 ON t2.cat_ParentID = t1.cat_id WHERE t1.cat_ParentID = 0