Browsing the archives for the MySQL category

MySQL fulltext searches

MySQL have a very nifty search function built in, which in many ways are more sophisticated than the WHERE LIKE (’%’). Using full text search with MATCH (…) AGAINST (…) AS relevancy it is also possible to get results ranked by relevancy. Here’s the quick, dirty way to do it:
1.  First we need to create [...]

Popularity: 8% [?]

Selecting / joining two tables in MySQL – explained

Trying to create MySQL queries can be a daunting task for the beginner and before understanding the logic it can be really confusing. A common task is to select related data from two tables to generate for example a list of blog posts, where you might want to also display the number of comments for [...]

Popularity: 7% [?]

Select a random row (like user or post) from your MySQL table

I have beein using all kinds of strange constructs to be able to select a random row (often user or post) from table, and then I stubled over this on sitepoint forums:
SELECT * FROM users WHERE age > 20 ORDER BY RAND() LIMIT1
One simple argument to the query! Awsome. Hope it helps you as much [...]

Popularity: 10% [?]