how to insert same record in one column but different row in mysql?

Ritsu

how can I insert the same records in two columns but different row without duplicating the two columns in the same row ?

I have two tables

structure table rek

  • rek int (Primary Key)
  • name varchar (10)
  • address varchar (15)

structure table cek

  • cek int (Primary Key)
  • rek int (Foreign Key)
  • date date

table rek

rek   name   address
001   Jane   Alaska
002   Amel   Washington
003   John   Virginia

table cek (I would like my output to look like the table below.)

cek    rek   date
01     002   12-05-2015
01     003   12-05-2015
02     002   13-05-2015
03     001   12-05-2015

how can I insert in table cek if I want output like table cek? When I trying to insert the data as shown in the above table I can't. When I removed the primary key from cek, the data was duplicated.

Tushar Purohit

From your second table cek remove primary key and Fk from both the columns. and create composite primary key on column (cek,rek) in this way in your words you can record in two columns but different row without duplicating the two columns in the same row ... or else the best thing to do is to create bridging table between these two columns

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How to show a column with the same id in one row

分類Dev

How to copy a row and insert in same table with a autoincrement field in MySQL?

分類Dev

Include row number as column in MySQL INSERT

分類Dev

Write a query that shows record counts for different conditions on the same row

分類Dev

How to calculate different avg for the same record?

分類Dev

how to select multiple same column in one column

分類Dev

mysql insert unique values from one column to a column of another table

分類Dev

Select only one checkbox/radiobutton in the same row and column

分類Dev

How insert a list as a column in MySQL with Python?

分類Dev

MySQL: Insert record if not exists in table

分類Dev

How to delete duplicate record which has one unique column

分類Dev

how can I insert an element to Numpy matrix by row and column indices

分類Dev

How to order by one column, but rank based on a different column that is not numeric?

分類Dev

How to Insert Different XML Field values into table column

分類Dev

Update value of one table with other values of same column with different condition in same table

分類Dev

Find values in one column that share same value in different column without knowing the 2nd cols value

分類Dev

How to process different row in tensor based on the first column value in tensorflow

分類Dev

How to get value of last valid index of a different column for each row

分類Dev

How to add multiple rows with the same value and ID in one row

分類Dev

PHP MySQL script shows no error but won't insert row (more details and different code)

分類Dev

How to combine multiple rows into one row and multiple column in SQL Server?

分類Dev

How to give one column space in every next row of grid display

分類Dev

How to create multiple column in an one row UITableViewCell in swift?

分類Dev

How to "count" two different criteria from the same column in a table?

分類Dev

How to get data by using different column values refrencing same table

分類Dev

DateDiff in MySQL with same column

分類Dev

How to add new rows with different value in one column in R

分類Dev

how to replace a column with different strings to one string R?

分類Dev

How to compare two tables with one column that is slightly different in PowerShell?

Related 関連記事

  1. 1

    How to show a column with the same id in one row

  2. 2

    How to copy a row and insert in same table with a autoincrement field in MySQL?

  3. 3

    Include row number as column in MySQL INSERT

  4. 4

    Write a query that shows record counts for different conditions on the same row

  5. 5

    How to calculate different avg for the same record?

  6. 6

    how to select multiple same column in one column

  7. 7

    mysql insert unique values from one column to a column of another table

  8. 8

    Select only one checkbox/radiobutton in the same row and column

  9. 9

    How insert a list as a column in MySQL with Python?

  10. 10

    MySQL: Insert record if not exists in table

  11. 11

    How to delete duplicate record which has one unique column

  12. 12

    how can I insert an element to Numpy matrix by row and column indices

  13. 13

    How to order by one column, but rank based on a different column that is not numeric?

  14. 14

    How to Insert Different XML Field values into table column

  15. 15

    Update value of one table with other values of same column with different condition in same table

  16. 16

    Find values in one column that share same value in different column without knowing the 2nd cols value

  17. 17

    How to process different row in tensor based on the first column value in tensorflow

  18. 18

    How to get value of last valid index of a different column for each row

  19. 19

    How to add multiple rows with the same value and ID in one row

  20. 20

    PHP MySQL script shows no error but won't insert row (more details and different code)

  21. 21

    How to combine multiple rows into one row and multiple column in SQL Server?

  22. 22

    How to give one column space in every next row of grid display

  23. 23

    How to create multiple column in an one row UITableViewCell in swift?

  24. 24

    How to "count" two different criteria from the same column in a table?

  25. 25

    How to get data by using different column values refrencing same table

  26. 26

    DateDiff in MySQL with same column

  27. 27

    How to add new rows with different value in one column in R

  28. 28

    how to replace a column with different strings to one string R?

  29. 29

    How to compare two tables with one column that is slightly different in PowerShell?

ホットタグ

アーカイブ