What’s the difference between TRUNCATE and DELETE in SQL

Here’s a list of differences. I’ve highlighted Oracle-specific features, and hopefully the community can add in other vendors’ specific difference also. Differences that are common to most vendors can go directly below the headings, with differences highlighted below. General Overview If you want to quickly delete all of the rows from a table, and you’re … Read more

How can I return pivot table output in MySQL?

This basically is a pivot table. A nice tutorial on how to achieve this can be found here: http://www.artfulsoftware.com/infotree/qrytip.php?id=78 I advise reading this post and adapt this solution to your needs. Update After the link above is currently not available any longer I feel obliged to provide some additional information for all of you searching … Read more

Find records from one table which don’t exist in another

There’s several different ways of doing this, with varying efficiency, depending on how good your query optimiser is, and the relative size of your two tables: This is the shortest statement, and may be quickest if your phone book is very short: SELECT * FROM Call WHERE phone_number NOT IN (SELECT phone_number FROM Phone_book) alternatively … Read more

MySQL query String contains

Quite simple actually: SELECT * FROM `table` WHERE `column` LIKE ‘%{$needle}%’ The % is a wildcard for any characters set (none, one or many). Do note that this can get slow on very large datasets so if your database grows you’ll need to use fulltext indices.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)