hello,

I have a simple problem. I need to create a new table "smaller" using the data from an old table "larger" table. When I say smaller I mean it will have the exact structure as the older table but will have only a few records.

Now, i know that i can use:

CREATE TABLE new_table_name SELECT * FROM old_table_name WHERE id >= 1 AND id <= 5;"

but the problem is that i want to SELECT multiple sets of records. So in the example above I select WHERE id>= 1 AND id <=5 but say I also want to have id >= 10 AND id <=15 would I just do this:

CREATE TABLE new_table_name SELECT * FROM old_table_name WHERE (id >= 1 AND id <= 5) (id >= 10 AND id <= 15);"

I am using php. The usr decides what records are to be added into the new table and they are given multiple input text fields for each starting id and finishing id. I want to be able to do this with one query!

User input interface:
New Table Name : _______________
Starting ID : ___ , ___ , ___ , ___ , ___
Finishing ID : ___ , ___ , ___ , ___ , ___

Thanks for your help.

The only thing missing is an OR:

WHERE (id >= 1 AND id <= 5) OR (id >= 10 AND id <= 15)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.