Jump to content

[SOLVED] mysql want to auto create a table from existing data


Recommended Posts

Hi all

 

I have a problem that i would like to rectify in one of two ways.

 

1. auto create a table in mysql from existing data that is atuomatically updated

2. use an appropriate "select" php call methos to get the data

 

I am using a search function to search the data base that uses multiple fields. ie height, build gender etc.

 

This is then passed through a php system the get the results. however the existing database holds the results needed in this form:

 

CREATE TABLE IF NOT EXISTS `table` (

  `id` int(10) NOT NULL auto_increment,

  `user_id` int(11) NOT NULL,

  `field_id` int(10) NOT NULL,

  `value` text NOT NULL,

  PRIMARY KEY  (`id`),

  FULLTEXT KEY `search` (`value`)

) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=403 ;

 

 

The field id drags from another table that holds the field values only. All the data that i am trying to search exists in the "value" column and is in a format as such:

 

iduser_idfield_idvalue

1622female

262155ft 6

36213slender

 

I am currently using the following code to try and get the results, however they are not passing through correctly as they only search for one individual value and not multiple. The join feature works fine.

 

SELECT * FROM table a JOIN table2 b ON a.user_id = b.userid JOIN jos_users c ON b.userid = c.id WHERE value LIKE '%$gender%' AND '%height'% %'build%' 

 

So as questioned above. is there a way to create and new auto updated Mysql table to pull data from, or is there a Select method i can use that will allow me search and retrieve only the users with the value fields selected

 

Sorry its a bit of a mind boggle!

 

Thanks in advance!

That's not very normalized, now, is it?

 

ha ha tell me about it, got a client using jom social for joomla and wanting a dynamic search so the tables are predefined unfortunately, just working ways around it.

 

so what would the multiple entail please?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.