Note that there are some explanatory texts on larger screens.

plurals
  1. POsql Column with multiple values (query implementation in a cpp file )
    primarykey
    data
    text
    <p>I am using <a href="http://ftp.nchu.edu.tw/MySQL/tech-resources/articles/mysql-capi-tutorial.html" rel="nofollow">this</a> link.</p> <p>I have connected my cpp file with Eclipse to my Database with 3 tables (two simple tables <code>Person</code> and <code>Item</code> and a third one <code>PersonItem</code> that connects them). In the third table I use one simple primary and then two foreign keys like that:</p> <pre><code>CREATE TABLE PersonsItems(PersonsItemsId int not null auto_increment primary key, Person_Id int not null, Item_id int not null, constraint fk_Person_id foreign key (Person_Id) references Person(PersonId), constraint fk_Item_id foreign key (Item_id) references Items(ItemId)); </code></pre> <p>So, then with embedded sql in c I want a Person to have multiple items.</p> <p>My code:</p> <pre><code> mysql_query(connection, \ "INSERT INTO PersonsItems(PersonsItemsId, Person_Id, Item_id) VALUES (1,1,5), (1,1,8);"); printf("%ld PersonsItems Row(s) Updated!\n", (long) mysql_affected_rows(connection)); //SELECT newly inserted record. mysql_query(connection, \ "SELECT Order_id FROM PersonsItems"); //Resource struct with rows of returned data. resource = mysql_use_result(connection); // Fetch multiple results while((result = mysql_fetch_row(resource))) { printf("%s %s\n",result[0], result[1]); } </code></pre> <p>My result is </p> <pre><code>-1 PersonsItems Row(s) Updated! 5 </code></pre> <p>but with <code>VALUES (1,1,5), (1,1,8);</code></p> <p>I would like that to be </p> <pre><code>-1 PersonsItems Row(s) Updated! 5 8 </code></pre> <p>Can somone tell me why is this not happening? Kind regards.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload