The Question : 1027 people think this question is useful There is a table messages that contains data as shown below: If I run a query select * from messages group by name, I will get the result as: What query will return the following result? That is, the last record in each group should
The Question : 992 people think this question is useful The MySQL manual at MySQL covers this. Usually I just dump the database and reimport it with a new name. This is not an option for very big databases. Apparently RENAME {DATABASE | SCHEMA} db_name TO new_db_name; does bad things, exist only in a handful
The Question : 984 people think this question is useful For simplicity, assume all relevant fields are NOT NULL. You can do: Or else: Do these two work on the same way in MySQL? The Question Comments : @Marco: here it is possible duplicate of SQL left join vs multiple tables on FROM line? If
The Question : 968 people think this question is useful I am trying to select data from a MySQL table, but I get one of the following error messages: mysql_fetch_array() expects parameter 1 to be resource, boolean given This is my code: The Question Comments : you can get more useful eroor msg using:: QUERY
The Question : 889 people think this question is useful I am an old-school MySQL user and have always preferred JOIN over sub-query. But nowadays everyone uses sub-query, and I hate it; I don’t know why. I lack the theoretical knowledge to judge for myself if there is any difference. Is a sub-query as good
The Question : 922 people think this question is useful How do you set a default value for a MySQL Datetime column? In SQL Server it’s getdate(). What is the equivalant for MySQL? I’m using MySQL 5.x if that is a factor. The Question Comments : I use CURRENT_TIMESTAMP in my mysql table (not in
The Question : 947 people think this question is useful I can run this query to get the sizes of all tables in a MySQL database: I would like some help in understanding the results. I am looking for tables with the largest sizes. Which column should I look at? The Question Comments : What
The Question : 933 people think this question is useful I want to add a row to a database table, but if a row exists with the same unique key I want to update the row. For example: Let’s say the unique key is ID, and in my Database, there is a row with ID
The Question : 865 people think this question is useful Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago. Improve this question I’m working on a projects which
The Question : 885 people think this question is useful I have 2-3 different column names that I want to look up in the entire DB and list out all tables which have those columns. Any easy script? The Question Comments : Refer this: winashwin.wordpress.com/2012/08/28/mysql-search The Answer 1 1452 people think this answer is useful
The Question : 885 people think this question is useful I started by googling, and found this article which talks about mutex tables. I have a table with ~14 million records. If I want to add more data in the same format, is there a way to ensure the record I want to insert does
The Question : 906 people think this question is useful I have a table: Now I want to make the columns user, email, address unique (together). How do I do this in MySql? Of course the example is just… an example. So please don’t worry about the semantics. The Question Comments : The Answer 1