D
D
Dmitry2019-02-23 10:23:29
MySQL
Dmitry, 2019-02-23 10:23:29

Why is there extra data in the query result?

Why as a result of the request

SELECT * FROM `wp_postmeta` WHERE `post_id`=73 AND `meta_key`='_regular_price' OR `meta_key`='_sale_price'

such a result?
5c70f4aa74c2b634893290.jpeg
Why did other post_ids get into the result?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
luna3956, 2019-02-23
@ddimonn8080

Потому что приоритет операции AND выше чем у операции OR. У вас идет выборка либо такие записи `post_id`=73 AND `meta_key`='_regular_price' либо такие `meta_key`='_sale_price'.
Поставьте скобки и все будет как хотите вот так:

`post_id`=73 AND (`meta_key`='_regular_price' OR `meta_key`='_sale_price')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question