Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7278421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:52:20+00:00 2026-05-28T22:52:20+00:00

asset_property table: | asset_id | property_id | property_value | |:——–:|:———–:|:—————| | 146 | 1

  • 0

asset_property table:

| asset_id | property_id | property_value |
|:--------:|:-----------:|:---------------|
| 146      | 1           | 4G             |
| 146      | 3           | 68723-239Gs    |
| 147      | 1           | A7             |

This is my query:

INSERT INTO asset_property (asset_id, property_id, property_value)
VALUES
  (146, 1, '4G'),
  (146, 2, 'Black & Decker'),
  (146, 3, ''),
ON DUPLICATE KEY
UPDATE property_value = VALUES(property_value);

Is there a way to say something like this:

INSERT INTO asset_property (asset_id, property_id, property_value)
VALUES
  (146, 1, '4G'),
  (146, 2, 'Black & Decker'),
  (146, 3, ''),
ON DUPLICATE KEY
UPDATE property_value = VALUES(property_value)
ON VALUES(property_value) IS NULL
DELETE FROM asset_property
WHERE asset_id = VALUES(asset_id)
AND property_id = VALUES(property_id);

Or I could use PHP to determine empty property_value sets and build a second query. So I would need this:

DELETE FROM asset_property
WHERE 'PRIMARY KEY' IN ('146-3');

The syntax is okay, but 0 rows are affected.

I’ve tried this:

SELECT 'PRIMARY KEY' FROM asset_property WHERE asset_id = 146;

But the result is:

| PRIMARY KEY |
|:------------|
| PRIMARY KEY |
| PRIMARY KEY |

The MySQL Manual seams to say you can’t.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T22:52:21+00:00Added an answer on May 28, 2026 at 10:52 pm
    DELETE FROM asset_property
    WHERE 'PRIMARY KEY' IN ('146-3');
    

    The syntax is okay, but 0 rows are affected.

    There aren’t any syntax errors, but that doesn’t mean it’s okay 🙂 @rodrigoap has already explained what that one means, and why 0 rows match.

    If you need to delete several records matching a composite primary key, you’re going to have to do one of these:

    DELETE FROM asset_property
    WHERE (asset_id = 146 AND property_id = 3)
       OR (asset_id = 146 AND property_id = 7)
       OR (asset_id = 146 AND property_id = 18)
    

    or concatenate the fields and test that:

    DELETE FROM asset_property
    WHERE CONCAT(asset_id, '-', property_id) in ('146-3', '146-7', '146-18')
    

    (this one will be slower, because it can’t take advantage of any indexes)

    or just execute multiple delete statements inside of a transaction:

    BEGIN
    DELETE FROM asset_property
    WHERE asset_id = 146 AND property_id = 3
    DELETE FROM asset_property
    WHERE asset_id = 146 AND property_id = 7
    DELETE FROM asset_property
    WHERE asset_id = 146 AND property_id = 18
    COMMIT
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can i solve this error:Column 'ASSET' does not belong to table . ?
I've got a table which contains a bunch of assets that are organized into
I am trying to insert data into MS SQL server 2008 using Ole DB.
Consider this command, as written here: Command.CommandText = SELECT COUNT(ASSET) AS POSEXISTS FROM POSITIONS
I am trying to write a SQL query that pulls from 3 tables and
(This looks like a long question, but it's not really, honest!) I am trying
I'm using NHibernate Search for NHibernate 3.0 GA. I have this code in my
I created a UserControl and added a label asset. I gave this label a
I'm using BulkLoader to load in images, SWFs, XML, etc into a game. When
I have a Activity entity, this entity can have several Task. Here the code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.