How do I say this:

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
User avatar
wvoyance
Forum Contributor
Posts: 135
Joined: Tue Apr 17, 2012 8:24 pm

How do I say this:

Post by wvoyance »

If I delete one record the SQL is

DELETE FROM `products_description` WHERE `products_description`.`products_id` = 1213 AND `products_description`.`language_id` = 1 LIMIT 1

If I want to delete from products_id =1000 to 1213
irrespect of other field how do I say it?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How do I say this:

Post by Celauran »

Code: Select all

DELETE FROM products_description
WHERE product_id >= 1000 AND product_id <= 1213

Code: Select all

DELETE FROM products_description
WHERE product_id BETWEEN 1000 AND 1213
User avatar
wvoyance
Forum Contributor
Posts: 135
Joined: Tue Apr 17, 2012 8:24 pm

Re: How do I say this:

Post by wvoyance »

do i need a quotation mark for 'products_description' etc?
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: How do I say this:

Post by social_experiment »

wvoyance wrote:do i need a quotation mark for 'products_description' etc?
For the values you can use single quotes (') and for table fields, table names you can encase them in backticks (`)
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
User avatar
wvoyance
Forum Contributor
Posts: 135
Joined: Tue Apr 17, 2012 8:24 pm

Re: How do I say this:

Post by wvoyance »

do i have to use quote? It seems no quote also work fine.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How do I say this:

Post by Celauran »

Given that the values are numerical, you don't need quotes. Putting backticks around table and field names is good practice, though.
Post Reply