mysql restore to different database

@minaz answer was good, but I want to append a little bit more. The problem was caused by –databases keyword. If you omit the keyword, it will not contain any database creation contents. So, Dump without –databases keyword. mysqldump -u username -p database_name > dump.sql And restore it with the target database name. mysql -u … Read more

SQL – Check if a column auto increments

For MySql, Check in the EXTRA column: SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = ‘my_table’ AND COLUMN_NAME = ‘my_column’ AND DATA_TYPE = ‘int’ AND COLUMN_DEFAULT IS NULL AND IS_NULLABLE = ‘NO’ AND EXTRA like ‘%auto_increment%’ For Sql Server, use sys.columns and the is_identity column: SELECT is_identity FROM sys.columns WHERE object_id = object_id(‘my_table’) AND name=”my_column”

MySQL Multiple Where Clause

I think that you are after this: SELECT image_id FROM list WHERE (style_id, style_value) IN ((24,’red’),(25,’big’),(27,’round’)) GROUP BY image_id HAVING count(distinct style_id, style_value)=3 You can’t use AND, because values can’t be 24 red and 25 big and 27 round at the same time in the same row, but you need to check the presence of … Read more

Mysql query to extract domains from urls

I had to combine some of the previous answers , plus a little more hackery for my data set . This is what works for me , it returns the domain and any sub-domains: SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX(target_url, “https://stackoverflow.com/”, 3), ‘://’, -1), “https://stackoverflow.com/”, 1), ‘?’, 1) AS domain Explanation ( cause non-trivial SQL rarely makes sense ): SUBSTRING_INDEX(target_url, … Read more

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