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
SELECT * FROM 'table' WHERE name IN ('abs', 'airbag_id', 'alarm')
This code make: 'abs' OR 'airbag_id' OR 'alarm'
I need to make: 'abs' AND 'airbag_id' AND 'alarm'
How can I do it with something like "IN".
I don't need something like this:
SELECT * FROM 'table' WHERE name = 'abs' AND name = 'airbag_id' AND name = 'alarm'
...because I will use to many AND's.
Any idea?
You probably need a single column result having all these names. You can do it like this
SELECT some_column_you_group_by
FROM your_table
WHERE name IN ('abs', 'airbag_id', 'alarm')
group by some_column_you_group_by
having count(distinct name) = 3
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have a table which stores student details like name,Phone no,address and other basic details.In address field stores student address like : ABC apartment;Lat:21.1111;Long:71.1111.Now I want to write a MySQL select query that gives me only 21.1111 and 71.1111 as result.which matching function should i use to get the required result.
SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(`address`, 'Lat:', -1), ';', 1) AS Latitude,
SUBSTRING_INDEX(SUBSTRING_INDEX(`address`, 'Long:', -1), ';', 1) AS Longtude
FROM student_details;
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 6 years ago.
Improve this question
Trying to query db. I need to show all fields, but need to exclude one name that is in the db.
Example:
The db contains column 'marketer' when I try to query it I don't want marketer 'Tommy' but all the others. I have tried tried where clause with all the names and not working.
This is the query you're looking for
SELECT * FROM <table_name> WHERE marketer<>'Tommy';
use the 'where' to add your conditions
SELECT * FROM your_table WHERE marketer!='Tommy'
For your Reference
http://www.w3schools.com/sql/sql_where.asp
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have table called TABLE_1 which has following columns:
id phone_number user_name country state
I want to search with this string " 1, 948583848, akash, usa,calfornia". How do I write a mysql query to get result form above Phone TABLE_1?
Is this the where clause that you want?
where concat_ws(', ', id, phone_number, user_name, country, state) = '1, 948583848, akash, usa,calfornia'
This seems like a very strange requirement. You are better off doing individual comparisons on the columns rather than concatenating the values together.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
How do I display all field names from a MySQL table to a web page when I only know the table name?
Use the information_schema meta-DB:
SELECT COLUMN_NAME
FROM information_schema.TABLES
WHERE (TABLE_SCHEMA='Yourdb') AND (TABLE_NAME = 'Yourtablename')
In addition to #MarcB's suggestion, you can also do:
SHOW COLUMNS FROM table
http://dev.mysql.com/doc/refman/5.6/en/show-columns.html
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 mysql database where there is 3 tables 'groupstage', 'quarterfinal,' semifinal. All of these table have a column named 'Date'. Now I want to write a query from where I can get all the fields from those tables with a specific date? what should i write it in php?
To get what you want, you can write a query which join the 3 tables like :
SELECT *
FROM groupstage, quarterfinal, semifinal
WHERE groupstage.date = quarterfinal.date AND quarterfinal.date = semifinal.date
AND date = "YOUR DATE"
In php you should just create a var $query = "My query above"