Tag Info

New answers tagged


If I have well understood your question, you should use the DECODE function in your query in the SELECT and GROUP BY sections. NB: for performance purpose, you might create an index using that function.


Have you tried: SELECT entity_id FROM customer_entity where entity_id NOT IN (SELECT sfo.customer_id FROM sales_flat_order sfo WHERE sfo.customer_id IS NOT NULL); This will probably work to get your results, if it "counts" as a valid answer to the business question you are hoping to answer.


Your query is close but doesn't work because no row will satisfy both text='wi-fi' AND text='bluetooth' at the same time. You could use a self join instead: SELECT pa1.* FROM product_attribute pa1 JOIN product_attribute pa2 ON pa1.product_id = pa2.product_id WHERE pa1.text = 'wi-fi' AND pa2.text = 'bluetooth' ; That way the first ...


This may work: SELECT product_attribute.product_id FROM product_attribute WHERE product_attribute.text = 'wi-fi' OR product_attribute.text = 'bluetooth' GROUP BY product_attribute.product_id HAVING COUNT(*) = 2; The idea here is to use an OR in the WHERE clause to allow rows that have either wi-fi or bluetooth in the text column, then we only return ...


GROUP BY wp_posts.ID indicates you want results to be returned for each unique wp_posts.ID value. Most likely, you need to replace that GROUP BY column with something else.


You could try this in your session SET autocommit = 0; SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; START TRANSACTION SELECT ... INSERT ... COMMIT; SERIALIZABLE causes SELECTs to do the locking for you Here is what the MySQL Documentation says on SERIALIZABLE This level is like REPEATABLE READ, but InnoDB implicitly converts all plain SELECT ...


With LOCK you probably mean locking entire table, that should not be needed in InnoDB. Check SELECT .. FOR UPDATE. But duplicate values should be forbidden with the use of UNIQUE indexes, that way the worst thing you get is an "suplicate key" error and not a duplicated row. If you have proper indexes in place, you may even use INSERT .. ON DUPLICATE KEY ...


I used your @x from your previous question in my query below. I create a sample table with 2 rows that should behave just like your real table although my Name value is similar because I used @x twice (ID is not similar): declare @table table(id int, value xml); insert into @table(id, value) values(1, @x), (2, @x); Select t.id , x.y.value('@title', ...


use rank and partition, partition by year/month and rank order by count(user id) then you have users by they rank(translation count) in each partition(year/month) http://stackoverflow.com/questions/13962950/sql-rank-over-partition-on-joined-tables https://msdn.microsoft.com/en-us/library/ms189798.aspx

Top 50 recent answers are included