MySQL select issue ( unique ) [closed] - mysql

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a table with the following fields :
date / source / destination
The same source can go to the same destination but at different time.
Multiple sources can go to same destination, etc.
I am looking to extract all destinations that have unique sources.

Bit hard to try to help with so little info, but maybe this could work?
SELECT Destination
FROM tablename
GROUP BY Destination
HAVING COUNT(DISTINCT Source) = 1

Related

How to check details of user in intagram database, who never posted a photo via SQL [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 days ago.
Improve this question
I was given instagram database with some records and have 7 tables as follows:
Tables--
I am using MYSQL
I have a requirement check the User who have not posted a single photo using sql in MYSQL.
Any help will be appreciated
I tried to get details from Photo table using the query:

How do i edit multible rows in mysql based on a set of criteria [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 months ago.
Improve this question
I have a mysqlp table which contains a set of data as in the sample excel file. We need a query that will copy the product name into the customer field where customer = Luxury. We used the below query to start editing one by one but there are thousands of records.
SET customer = 'TAVERNAKI' WHERE product = 'TAVERNAKI' AND customer = 'LUXURY';
So we are going about copying and pasting the query and replacing the product name each time. Does anyone have an idea for a mass edit of all records?
Sample file in the link here
[1]: https://docs.google.com/spreadsheets/d/1sgtwNobMU5mKCLuxDLqhpEivEekI0l4R/edit?usp=sharing&ouid=107367920163394089177&rtpof=true&sd=true
Simply
UPDATE table SET customer=product WHERE customer='Luxury'

Want to change prefix of values in mysql database [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have millions of data in my database table customer. In that, I have the id_token attribute which has value like cus00001 format now I want to change it to ank00001.
What will be the query in rails or mysql to do it for all the data in the database?
You can use simple update query using REPLACE function:
UPDATE `table_name` SET `id_token` = REPLACE(`id_token`, 'ank', 'cus');

How to get a specific row of data for mysql with specification of company and agent [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
How to retrieve all the data pertaining to company name and agent from mysql? How to write the query statement?
Have you tried this?
SELECT *
FROM agent_info
WHERE policyCompany = 'Avia' and policyAgent = 'Ron';
I have to guess because you didn't tell us much about your tables, but this might work.
SELECT policyCompany,
GROUP_CONCAT(DISTINCT policyAgent ORDER BY policyAgent) agents
FROM mytable
GROUP BY policyCompany
You can read about GROUP_CONCAT() here.

MySQL to refer to row from same table [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I have a table named tblMitigation, which has several columns:
Headcode, Time, Origin, Destination, Mitigation, Next Service.
The Next Service column refers to another Headcode value in the same table. How can I use MySQL to look up the Mitigation column for that other service?
Thanks
Chris
You could JOIN the table to itself. Use a LEFT JOIN in case there is no Next Service as yet. The COALESCE will ensure the value of Next_Mitigation is something different in that case e.g. N/A
SELECT current.*, COALESCE(next.Mitigation, 'N/A') AS Next_Mitigation
FROM tblMitigation current
LEFT JOIN tblMitigation next ON next.Headcode = current.`Next Service`