What I’m trying to do is build a table of unique sets of rows. What is the aim? I’m building an app for a service provider (let’s say cable company for example). Every customer has a set of …
Tag: database
How to change query result into another value in MYSQL?
For example, I have a column named ‘form_type’ consisted of int (1-4) id_event|form_type ——–|———- 001 |1 001 |3 001 |4 002 |2 002 |1 When i query SELECT form_type …
SQL statement to update rows in a table, insert into/update same table
I have a seemingly pretty simple situation here, but one which I have never dealt with. I have researched the issue and have found situations pretty similar, but not close enough to run on a production db. I have 1 table with 2 columns. I want to find all entries that share the same values in column 1, and update
Seperate tables with same attributes in SQL
When using SQL database, when I have tables with same attributes. For example if I have [posts] with attributes (id, image, description, number of likes and dislikes) [Comments] with attributes (id, image, description, number of likes and dislikes) and [Replies] with attributes (id, image, description, number of likes and dislikes) and I have another type of posts, comments, replies for
Count of line item in MySQL
I have a complex query joined to multiple tables to show a “transaction history”, I want a quick and easy way to count the occurrences of order_id to make it as the line_number. I had it done with code but for performance reason I want to have it done with MySQL. Here is an example of what I have: This
How to JOIN postmeta table and get the posts before the date of custom field using SQL
I’d like to combine wp_posts table and wp_postmeta table and get the posts before the date of custom field. Code with only wp_posts table is below and it works fine I want to add “postmeta table” to “post table” and get only posts before the date of custom field if it is “WP_Query”, meta query would be below I tried
Postgresql Select and display one column based on another column
WALLET TABLE ID IS_SPEND HOWMUCH true. 500 false. 1000 true. 5 I want to calculate how much money I have after several transactions. spend as spend money and not spend as earn money I tried But it cannot reach my goal. I don’t know how can I get the result I want, just output 495 is perfect. Answer You seem
SQL select the latest record on joined tables
I want to retrieve the property which an user paid a tax last. have two tables person_properties and property_taxes What I tried so far: This gives me the person_id along the max year. But I actually need the property_id, the property which an user paid last. If I replace pp.person_id by pp.property_id, I then get all properties, of course.. not
How to make this Query without using UNION?
I am not very good at making query’s. So could someone explain and help me with this query? I need to inner join 2 tables ‘Slaap’ And ‘Eten’. i need all ‘eten’ where ID = 5 and i need all ‘Slaap’ where ID = 5. I could only achieve this with a UNION but that is what i dont want
Can’t delete records from the same table using NOT EXISTS MySQL syntax
I want to perform deletion in the same table. I’ve tried different ways, but I still can’t get it right. So, I got this error You can’t specify target table ‘tb’ for update in FROM clause. I tried aliasing the tables, but nothing done. I can’t figure out what is missing. I appreciate any ideas. Answer MySQL supports JOINs in