php / mysql to query one table with multiple identical fields and create one unique entry for each field in a second table

kerry

A bit difficult to explain this one. I have a table of transactions which contains multiple entries of names. I want to scan this table and create a unique entry for each name in a second table. For instance table 1 contains :-

john smith pete jones sue james john smith john smith pete jones sue james john smith

after the query I want table 2 to contain:-

john smith pete jones sue james

thanks for any advice

John Roca

You got to use DISTINCT keyword in sql. It selects distinct values.

SELECT DISTINCT name from table_1 

And you will retrieve unique names. And all you have to do is to loop through in the search result and do an INSERT statement to insert to your new table.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

PHP/MySQL - Get multiple fields from one entry in a table

From Dev

MySQL trigger works on one field, not on second field, in the same table

From Dev

MySQL query to return all fields of a table grouped by one field but only where that grouping has more than one value in another field

From Dev

How can I parse one field into multiple fields in the same table?

From Dev

MySQL query - single row in one table with multiple rows in another table

From Dev

MySQL: Return row count from second table using one query

From Dev

How to copy data from one SQL table and create a new entry in a second, different table?

From Dev

join one row from one mysql table to multiple row in second table

From Dev

COUNT query with mysql with condition from one field from table

From Dev

MySQL Query from one table - Select same field twice

From Dev

One field identical, one field different (MySQL)

From Dev

PHP: two table in one query

From Dev

PHP: two table in one query

From Dev

Group by one field and display multiple fields (MySQL)

From Dev

One MySQL Database & Multiple Table

From Dev

mysql multiple grouping on one table

From Dev

mysql query combine table from one table

From Dev

mysql query combine table from one table

From Dev

MySQL multiple values join to one table - better query?

From Dev

Mysql Query for inserting from one table to another on Multiple conditions and columns

From Dev

Mysql Query for inserting from one table to another on Multiple conditions and columns

From Dev

MySQL JOIN one of the rows from second table

From Dev

Joining multiple fields to one in another table

From Dev

SQL - Where In one table not the other (Multiple Fields)

From Dev

Combine multiple table results into one table in php

From Dev

How to Relate Two Fields in One Table to One Field in Another

From Dev

One table with many field or two table with fewer fields?

From Dev

Validate fields from one table to another in MySQL

From Dev

SQL Query that joins one table where the second table has duplicates

Related Related

  1. 1

    PHP/MySQL - Get multiple fields from one entry in a table

  2. 2

    MySQL trigger works on one field, not on second field, in the same table

  3. 3

    MySQL query to return all fields of a table grouped by one field but only where that grouping has more than one value in another field

  4. 4

    How can I parse one field into multiple fields in the same table?

  5. 5

    MySQL query - single row in one table with multiple rows in another table

  6. 6

    MySQL: Return row count from second table using one query

  7. 7

    How to copy data from one SQL table and create a new entry in a second, different table?

  8. 8

    join one row from one mysql table to multiple row in second table

  9. 9

    COUNT query with mysql with condition from one field from table

  10. 10

    MySQL Query from one table - Select same field twice

  11. 11

    One field identical, one field different (MySQL)

  12. 12

    PHP: two table in one query

  13. 13

    PHP: two table in one query

  14. 14

    Group by one field and display multiple fields (MySQL)

  15. 15

    One MySQL Database & Multiple Table

  16. 16

    mysql multiple grouping on one table

  17. 17

    mysql query combine table from one table

  18. 18

    mysql query combine table from one table

  19. 19

    MySQL multiple values join to one table - better query?

  20. 20

    Mysql Query for inserting from one table to another on Multiple conditions and columns

  21. 21

    Mysql Query for inserting from one table to another on Multiple conditions and columns

  22. 22

    MySQL JOIN one of the rows from second table

  23. 23

    Joining multiple fields to one in another table

  24. 24

    SQL - Where In one table not the other (Multiple Fields)

  25. 25

    Combine multiple table results into one table in php

  26. 26

    How to Relate Two Fields in One Table to One Field in Another

  27. 27

    One table with many field or two table with fewer fields?

  28. 28

    Validate fields from one table to another in MySQL

  29. 29

    SQL Query that joins one table where the second table has duplicates

HotTag

Archive