[eluser]jedd[/eluser]
[quote author="georgerobbo" date="1255041993"]
I am not developing this project in CodeIgniter.
[/quote]
Why are you posting on the CI forums, then?
[quote author="georgerobbo" date="1254921761"]
I have created a new table for tags.
...
Apologies. The structure of my table, named user is as follows.
Code:
ID(int)(11)
name(varchar)(25)
type(varchar)(50)
tag(varchar) (200)
permalink(varchar)(100)
description(varchar)(255)
address_ln1(varchar)(50)
address_ln2(varchar)(50)
town(varchar)(25)
postcode(varchar)(8)
phone(varchar)(12)
[/quote]
It looks like you have not, in fact, created a tag table.
To answer your question - how to write better queries - relies upon you having a better schema.
This in turn relies on you having a table to hold tags, and a table to manage the relationship between users and tags.
The former would look like this:
Code:
CREATE TABLE tag (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
name CHAR(100) UNIQUE NOT NULL,
PRIMARY KEY(id),
INDEX (name),
);
The latter would look like this:
Code:
CREATE TABLE tag_user (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
tag_id INT UNSIGNED NOT NULL,
user_id INT UNSIGNED NOT NULL,
PRIMARY KEY(id),
INDEX (tag_id),
INDEX (user_id),
);
Needless to say, you remove the tag column from your user table.