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.
Related
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
How can I add a grouping for the "retirements" table by the "id_type" field and not just for everyone?
select name,
sum(retirements.price_per_product)
from retirements
join type_of_products top on retirements.id_product = top.id
where (date between '1998-11-01' and '1998-11-14')
group by name;
Do not resort to aggregate functions of each type? It's so rude.
There are two different ways to achieve this.
1. You may use a sub-query but it is expensive in terms of performance.
2. You may utilize the #temp table and join it in later part. A downside is it is
longer to code but performance is good especially in the long run.
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
What are the best practices for writing a query to search for Orphan records?
There isn't a way to insert a table name dynamically. However, it sounds like you're wanting to define a view, instead of a table. You could do something like this, though:
CREATE VIEW `orphaned_tables` (`table_name`, `id`) AS
SELECT 'TABLE_A', id FROM TABLE_A
WHERE /* Check if table a's id is orphaned */
UNION
SELECT 'TABLE_B', id FROM TABLE_B
WHERE /* Check if table b's id is orphaned */
UNION
...
By creating it as a view, you won't have to worry about inserting data; when you select it, it will always have the table name and orphaned IDs.
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 had a table named table1 and have a three column.. column1, column2,column3..
I want to view the value of my columns in table using VIEW statement not SELECT is it possible?
Thank in advance#
No. View is a SQL database concept. You will have to use SELECT... to create a query, which is essentially the same thing. MSAccess has no concept of Views, it uses Queries.
A view is an SQL query that has been given a name and stored in the database. That is exactly what the Access queries are.
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.
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.