• Member for 10 years, 1 month
  • Last seen more than a week ago
Finding rows for a specified date range
3 votes

It seems that the following code solves my problem: SELECT DISTINCT groupid FROM pupilgroupteacher x WHERE teacherid=@teacher AND startdate<@month+INTERVAL 1 MONTH AND NOT EXISTS( SELECT * FROM ...

View answer
Adding an index without a lag (PostgreSQL)
2 votes

See Building Indexes Concurrently in PostgreSQL documentation. CONCURRENTLY option of CREATE INDEX solves the problem in an easy way. Just add it to CREATE INDEX. Be aware that while CONCURRENTLY ...

View answer
Several variants of a string in tables
1 votes

I decided to do it in the following way: Make a table strings with an ID and a VARCHAR, which will store both URLs and keywords, both normalized forms and unmodified user input. Make a table seo ...

View answer
Getting the first day of week
1 votes

I found a solution in comments of http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html SELECT DATE_ADD(day, INTERVAL (7 - DAYOFWEEK(day)) DAY) AS day, AVG(position) AS position FROM ...

View answer
Replace some rows in one table with rows of another table
Accepted answer
0 votes

We can use mysqldump --replace --where "..." db table. It will output the REPLACE statement. It remains to edit this REPLACE to change the table name and then execute this SQL code.

View answer