Page 1 of 1
Difficult one
Posted: Thu Sep 08, 2011 1:27 pm
by jeowd
I am working on a Minecraft website project. I have a table in the database with the in game data value for blocks(only ones that cannot be crafted). I want to have a separate table for those which can be crafted in to things like Pistons. How would I be able to do a query where it will return all craft recipes that have cobblestone as an example? I was thinking of an array but unsure how it would work
Thanks
Re: Difficult one
Posted: Thu Sep 08, 2011 5:21 pm
by Torniquet
How is the table layed out?
if all materials needed are in a single field then use like and the wildcard
SELECT * FROM recepies WHERE materials LIKE "%cobblestone%"
if each material has its own field then you could do something like
SELECT * FROM recepies WHERE material_1 = "cobblestone" OR material_2 = "cobblestone" etc....
Thats how i would query it, but no doubt there is a better way lol.
Re: Difficult one
Posted: Thu Sep 08, 2011 6:27 pm
by jeowd
Torniquet wrote:How is the table layed out?
if all materials needed are in a single field then use like and the wildcard
SELECT * FROM recepies WHERE materials LIKE "%cobblestone%"
if each material has its own field then you could do something like
SELECT * FROM recepies WHERE material_1 = "cobblestone" OR material_2 = "cobblestone" etc....
Thats how i would query it, but no doubt there is a better way lol.
Thanks, but what happens if someone queries stone and it returns cobblestone. I'm sure there will be a way to do it more specific
Re: Difficult one
Posted: Thu Sep 08, 2011 11:11 pm
by jacek
Can you post your table structure ?