multiple items for one service problem

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
ezi_pro
Forum Newbie
Posts: 3
Joined: Mon Feb 07, 2011 2:09 am

multiple items for one service problem

Post by ezi_pro »

how can i make a mysql database that supports a
1. title
2. then a list of services the user inputs that is then displayed

the problem im running into is that how can i sync the title with the possibly infinite number of services.

i want each service to be individual

would i have to create a seperate table for the services?

maybe i could create a table with the auto increment ID then the title
then another table that has the ID of the corresponding first table with the quotes

so it would look like this

service title table:
(auto increment id,
service title)

service list table:
(id from first table,
services)

so then how would i get a query that would pull these tables together?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: multiple items for one service problem

Post by AbraCadaver »

Seems like you're on the right track. I would add a unique id for the service as well:
[text]service_title
id
title

service_list
id
title_id
service[/text]
[text]SELECT * FROM service_title, service_list WHERE service_title.id = service_list.title_id[/text]
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
ezi_pro
Forum Newbie
Posts: 3
Joined: Mon Feb 07, 2011 2:09 am

Re: multiple items for one service problem

Post by ezi_pro »

AbraCadaver wrote:Seems like you're on the right track. I would add a unique id for the service as well:
[text]service_title
id
title

service_list
id
title_id
service[/text]
[text]SELECT * FROM service_title, service_list WHERE service_title.id = service_list.title_id[/text]

Thanks for the query, looks good:)

ill try it out when i get the time, ive been busy with h/w lately

ill post my code up here soon

Edit - btw the id on the service list was a good call, that way i can edit each service individually as well:)
Post Reply