Skip to content
Advertisement

Tag: mysql

Indexes and multi column primary keys

In a MySQL database I have a table with the following primary key In my application I will also frequently be selecting on item by itself and less frequently on only invoice. I’m assuming I would benefit from indexes on these columns. MySQL does not complain when I define the following: But I don’t see any evidence (using DESCRIBE —

Group by date range on weeks/months interval

I’m using MySQL and I have the following table: I want to be able to generate reports like this, where periods are done in the last 4 weeks: or in the last 3 months: Any ideas how to make select queries that can generate the equivalent date range and clicks count? Answer

Export unicode data from mysql

I have some data in one of my mysql table stored as utf8. The data is some japanese text. I need to export it to excel. Could you tell how to do it? Exporting by SELECT … INTO OUTFILE returns some plain text file. I’m not sure how to read it back in excel so that japanese character would show

Join one row to multiple rows in another table

I have a table to entities (lets call them people) and properties (one person can have an arbitrary number of properties). Ex: People Properties I would like to write an efficient select that would select people based on age and return all or some of their properties. It’s also acceptable to return one of the properties and total property count.

Avoiding Nested Queries

How Important is it to avoid nested queries. I have always learnt to avoid them like a plague. But they are the most natural thing to me. When I am designing a query, the first thing I write is a nested query. Then I convert it to joins, which sometimes takes a lot of time to get right. And rarely

Advertisement