I have this table and what I need as an output is to have for each payment the number of payments that have been done with the same credit card. For example, for the first payment there would be 0 payments with the same credit card. for the second payment there would be 1 payment with the same credit card.
Tag: mysql
How to get Table field names at top of result array
Here is my Sample table: Here is My Query: Result for above query is: I need to get the field names in the first element of the array. Expected result array is: How can I modify the Query to get this result? Thanks in advance… Answer Display issues should generally be dealt with in application code, not SQL queries. If
Find turning points in rows with SQL or LINQ
Lest say I have the following data: Date Value 04.04.2019 | -1,7 05.04.2019 | -3,3 06.04.2019 | -4,4 07.04.2019 | -6,4 08.04.2019 | 5 11.04.2019 …
SQL merge two tables – get only one row for each key value
I’m trying to run an SQL command on my database. I have two tables, one for users, another one for posts. I want to find last post of each user. I tried following: SELECT b.`username`, b.`id`, c.`…
how to comparison LAG function in mysql
I got complicated problem in mysql. I have some table on mydatabase. sample docs(this is only simple sample, actual data are so many table that I have to join) table “merchant” table “transaction” I want to know the information of merchants transaction daily “before” and “after” to comparison like this below I tried with this query but that query didn’t
How to perform mysql query with goal of returning 2 rows when a single record is found in
This will return one row with a result of: How would it be possible to return multiple rows for a given column while retaining the other column field values. Essentially, adding rows on the fly when the conditions are met. My thought process attempted: Desired Result: Answer Are you looking for union all? Or a CROSS JOIN:
Get results from SELECT then UPDATE it into the database MySQL and PHP
I want to get the time average by using this command in PHP : so is this code below correct to combine update and avg: I have two requests: I want to UPDATE another column with the average, so how can I do that? When I use the above SELECT I got the HH:MM but I just want the minutes
I need to optimize tables and queries
I have 3 tables: info, data, link, there is a request for data: offer optimization options: a) tables b) request. Queries for creating tables: Thanks! Answer Never use commas in the FROM clause. Always use proper, explicit, standard, readable JOIN syntax: Second, for this query your indexes are probably fine. I would also recommend a primary key index on link:
Foreign Key on MySQL
I am new to SQL and I started building my own project. I am having issues creating a foreign key on my second table. . Please let me know what I am missing here. Answer The second CREATE TABLE statement should be:
How to take union and write into the same table?
I have a table A with columns (x, y, z) and I have another table B with columns (x, y, z), basically the same schema. I want to add those rows from B into A, which do not already exist in A, basically after the operation the union of A and B exist in table A. How do I do