Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Favorites infavorites:mine
infavorites:1234
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with Search options user 63584

All versions of MySQL (not Microsoft SQL Server). Please also add a version-specific tag like mysql-5.7 if that is relevant to the question.

1
vote
You can calculate the running sum using a variable: SET @runtot:=0; SELECT sq.date, sq.titles, sq.count, (@runtot := @runtot + sq.count) AS rt FROM ( SELECT DATE(post_date) AS date, concat(post_ …
answered May 8 '15 by zgguy
1
vote
If you have a fixed set of user attributes then your current design is OK. If you need to have custom attributes (i.e. users can add their own attributes) then you'll have to go with the solution Max …
answered Apr 20 '15 by zgguy
2
votes
You could expand your activities table so that instead of a single timestamp column, it includes two timestamps, ts_from and ts_to, that indicate the time period for which the row's data is applicable …
answered May 1 '15 by zgguy
4
votes
I assume you have multiple entries in shows, views table for each user. When joining all three together, you get more rows than you expect: if for some user you have x rows in table shows and y rows i …
answered Jun 7 '15 by zgguy
5
votes
are not something that you should avoid. So say you have 3 tables, links(link_id, url) tags(tag_id, tag) tags_links(tag_id, link_id) You want to find all links with tags in (php , mysql)? select … l.link_id, l.url from links l inner join link_tags lt on (l.link_id = lt.link_id) inner join tags t on (lt.tag_id = t.tag_id) where t.tag in ('php', 'mysql') links.link_id and tags.tag_id …
answered Apr 18 '15 by zgguy
5
votes
There is no silver bullet for performance problems, and partitioning is not one either. Every partition is essentially a table for itself. Hence queries that are written in a way that allows the dat …
answered Jul 18 '15 by zgguy
5
votes
The short and simple answer for databases in general is: no, the physical order of rows in a table is generally not the same as in some index on that table. In general (I say in general because there …
answered Dec 24 '15 by zgguy
3
votes
By suggestion of @RolandoMySQLDBA, I'm combining my comments into an answer. So, in many cases, LIMIT clause enables the database server to do less work before delivering the result. MySQL docs …
answered Jun 7 '15 by zgguy