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 years ago.
Improve this question
I retrieved records from Sphinx index through DISTINCT method using sphinx for large number of records...For the backup I'm going to retrieve data from mySQL for bulk records..
Is the same DISTINCT query works well for the mySQL table also..Or is there any other way for retrieving data from mySQL instead of DISTINCT for getting data from large data table without time delay...
If indexed, there isn't a difference between distinct and group by, some would argue that Distinct doesn't have to sort, however you can get this as well with the group by, if you order by null in mysql, so I would say they aren't different at all.
However, perhaps I am missing the question all together.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
1.insert into demotable1(list_of_all_columns) select * from demotable2 where some_condition;
2.insert into demotable1 select * from demotable2 where some_condition;
note: Table structure of demotable1 and demotable2 are same.
Which one of the above query statement is optimal?
"Optimal" -- They are the same.
MySQL will expand * into a list of columns as part of the parsing of the query. If you have a list of columns, it will verify that they are valid. So, no significant difference in performance. In general, performance of a query is dominated by fetching rows, not the details of what goes on inside the row.
"Desirable" --
On the other hand, * should not be used in most situations. What if you later added or deleted a column? Suddenly most queries with * in them would break. The main exception: You are simply dumping the data to see what is in the table.
Hence, option 3 is the only desirable version; it is unfortunate that it is not available.
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 1 year ago.
Improve this question
I am trying to join an old sql table with a new one but exclude the duplicate entries, this needs to be in a delphi program as well, and im a noob at that, any ideas?
These both keywords will make your data to combine and display in a single column.
Union - Removes the duplicate entries of the table
Union All - Includes the duplicate entries
It would be better if you provide an example with input and output, that would clarify your question the most.
you can use the union all operator instead of the union operator for joining two tables that not remove duplicates from the table.
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
if I had a mysql table that has, lets say 300 million rows, how would I search for a row using
SELECT id WHERE coloumn = "abc" ;
most efficiently? Can I prepare the data so it would help the sql searching through the data? Or does it parse the rows row by row?
The SQL 101 answer here is an index using CREATE INDEX:
CREATE INDEX column_index ON table_name (`column_name`)
This of course depends on your schema. You can index more than one column as well and can apply UNIQUE constraints to ensure that each value is used only once.
On large tables the CREATE INDEX operation will be brutally slow to create the first time, so schedule some downtime if necessary. Once created it will be kept up-to-date automatically.
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 want to load data from database but how to get data in specific colmun
More Explanation:
lets say that we have a table called players, Then we have three columns "Username, Password and E-mail"
Now, if we want to select the email of the player who called "Nezo" how we can do it ?
This is a straightforward SELECT statement. I'd take some time to familiarize myself with the MySQL manual on SELECT, since it is among the most basic MySQL commands.
In this case, our select_expr (SELECT expression) is going to be the column from the table we're looking for, E-mail, and we're going to need to restrict the query to only look at the e-mail of the user named 'Nezo' using a WHERE clause:
SELECT `E-mail` FROM `players` WHERE `Username` = 'Nezo';
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 a two table first is simple primary key based table and second table is keyvaluepair for maintaining records.
Now I want to get records from Table in a single object. If they come as comma separate it's good.
Suppose I have table
ID valueID.
When I will run select query I not want a list of rows. I want a single column (in a row) that I can get the information about all valueIds.
Could someone explain me how can I get them in one instead of list?
You probably want to use GROUP_CONCAT.
SELECT GROUP_CONCAT(valueID) FROM table
http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat
If you need both the ID and the valueID, you're better off sticking with an array.