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 want to extract each row from a table, but in random order. How can I do that? I tried using rand(), but I was not successful.
My database is named "permis54_permis-online-date" and my table is named: "intrebari".
Use ORDER BY RAND() MySQL:
SELECT column FROM intrebari
ORDER BY RAND()
select * from intrebari order by rand();
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 will developing e-commerce website but need some help from you.
When I run query "SELECT * FROM products_variations_option WHERE variations_id IN (31,41) ORDER BY product_variations_id ASC" then I am gating this output but I need 1 and second row, Means I want only product_variations_id= 75 because 31 and 41 both value found in only product_variations_id=75
The below query may give you desired output
SELECT variations_id, product_variations_id
FROM (SELECT *
FROM products_variations_option
WHERE variations_id IN (31,41)
ORDER BY product_variations_id ASC
) as t
GROUP BY variations_id
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 5 years ago.
Improve this question
I have a website in which admins can post news and updates but every time they add a new one it goes from the first one added downwards any idea how to fix this?
You want to sort on the datetime (or if that doesn't exist you could use the ID, but that is not how "it should be") in descending order instead of ascending.
Example query:
SELECT `title`, `text` FROM `news` ORDER BY `datetime` DESC LIMIT 5
https://dev.mysql.com/doc/refman/5.7/en/sorting-rows.html
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 6 years ago.
Improve this question
I would like to know how to choose the users that have the highest number of columns to match the columns of the logged in user.
order by sum matches conditions ex:
SELECT * FROM table where fColumn = 'name' and column2='value2' or colmun3='value3'
ORDER BY (
(column2='value2') + (column3='value3')
) DESC
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 years ago.
Improve this question
I have a table that have a CP value (numeric), for example, 28030, 28060, 27100 etc. And the user can introduce a number via PHP. I want to, having this number for example, 28050, order in MYSQL my table putting 28060 as the first position.
This is the basic of my table:
SELECT * FROM `tiendas` ORDER BY `CP`
ABS() will work. Here's a query that does the job:
SELECT
CP
FROM tiendas
ORDER BY ABS(CP- 28050) ASC
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 want to search number in my MySQL data. String is +310623212542 but the mysql row data is only 0623212542. How can i compare ? Please help i am new to the mysql
Use
In php
<?php
$search_text = substr('+310623212542',3);
mysqli_query("SELECT * FROM tbl WHERE search LIKE '%$search_text%'");
?>
or
in mysql
use SUBSTRING
SELECT * FROM tbl WHERE search = SUBSTRING('+310623212542' FROM 4)
Note: using substring in mysql impact performance issue, when large data present