Knowee
Questions
Features
Study Tools

Write a query to display the owner_name and mail id in which the string should end before the '@' symbol. Display the details of the buildings which are having the  email address and give an alias name as 'email_name' and display it in ascending order based on owner name

Question

Write a query to display the owner_name and mail id in which the string should end before the '@' symbol. Display the details of the buildings which are having the  email address and give an alias name as 'email_name' and display it in ascending order based on owner name

🧐 Not the exact question you are looking for?Go ask a question

Solution

It seems like you're asking for a SQL query. Here's how you can write it:

SELECT owner_name, 
       SUBSTRING_INDEX(mail_id, '@', 1) AS email_name
FROM buildings
WHERE mail_id IS NOT NULL
ORDER BY owner_name ASC;

Here's a step-by-step breakdown of the query:

  1. SELECT owner_name, SUBSTRING_INDEX(mail_id, '@', 1) AS email_name: This part of the query is selecting the owner_name and the part of the mail_id before the '@' symbol. The SUBSTRING_INDEX function is used to get the substring before the '@' symbol.

  2. FROM buildings: This part of the query specifies the table we are selecting the data from, which is the buildings table.

  3. WHERE mail_id IS NOT NULL: This part of the query is a condition that filters out the records where mail_id is not present.

  4. ORDER BY owner_name ASC: This part of the query sorts the result in ascending order by the owner_name.

Please replace buildings, owner_name, and mail_id with your actual table and column names if they are different.

This problem has been solved

Similar Questions

Write a query to display the owner_name, address and contact_number of the buildings which does not have an email_address. Display the records in ascending order based on their owner_name.

Write a query to display the first 3 characters of the owner_name and the contact_number of all buildings in ascending order based on the owner name of the building. Give an alias to the first 3 characters as 'name_code'.

Write a query to display all the owner_name and concatenate contact_number and email with a hyphen(-) separated . Display the records in descending order based on owner_name . Give an alias name as 'contact_details'.Note:1. Display only the owner name and concatenate contact_number and email with – seperated from building table.2. Specify the alias name without any mistake.3. Order by is mandatory4. Use CONCAT function5. Compare your executed result with the sample output given below.

Write a query to display the entire details of the 'building' whose owner_name starts with the letter 'M', Display the records in ascending order based on their owner_name.

Write a query to display the owner_name and contact_number of all building, Display the records in ascending order based on owner_name.

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.