Tag Archives: MySQL

Archive

Database date between query build file in CodeIgnitor administrator

ci_logo_flame

Here’s the path to DB file in CodeIgnitor admin end which contains query related stuff. Like building order, qhere and select blocks. One may want to do some debugging in this file. In this file i need to make no changes. Just for reference.

/administrator/system/database/DB_active_rec.php

Now here’s how once could make a BETWEEN query for a date field. I wanted records for last 30 days. Continue reading

How to update a mysql table with the count of another table while using like statement

While working on a web links directory i wanted to update categories table’s num_listings column with the count of listings under each category. The category id was stored something like this in listings table: Continue reading

A few notes on joining a MySQL table to itself to get unique combination of field data

Just a few notes on joining a MySQL table to itself to get unique combination of data stored in its fields.

Suppose we have a MySQL table named `keywords` having fields `word1`, `word2` and `word3`. Once we have got a few records inserted into this table we would want to show all possible combination of keywords stored in those fields. For example, a select query returns a following set of data: Continue reading

Fixing ‘mysql’ is not recognized as an internal or external command in Windows7

Having WAMP installed when i try to type mysql in my windows command prompt it would give me the following error: Continue reading

MYSQL custom sorting – order by field value

Yesterday i had a somewhat new (for me ) and different kind of requirement while displaying MySQL result on a page. I had a category menu in which masters and slaves were sorted alphabetically and in ascending order. Continue reading

Full-text search in MySQL

Normally, most of us use “SELECT * FROM table WHERE field1 LIKE ‘%$keyword%’” OR field2 LIKE ‘%$keyword%‘ ..etc” to search our table and get results. This is slow and inefficient approach, as it does return all (too many) rows in which it does find a match for “keyword” without caring for “relevancy” and time. Continue reading