This is a ONE-TO-N Relationship: Each Bailleur Has N fournisseur and each fournisseur has N bailleur
when i generated MPD I have a new table named fournir
IDF IDB
----+------
i want to insert data in "bailleur" by typing the name of founisseur which is namef and the IDF of "fournisseur" will be inserted into column IDF of table "bailleur" all this using c++
here is what ive tried i alredy inserted data in table "Fournisseur"
here im using bailleur in a class called bailleur
int qstate1;
MYSQL_ROW row1;
MYSQL_RES* res1;
void Bailleur::addb( MYSQL* conn){
string idf="";
cin.ignore(1, '\n');
cout << "Enter Nom du bailleur: ";
getline(cin, nomb);
cout << "Enter Adresse: ";
getline(cin, adresseb);
cout << "Enter tel : ";
getline(cin, telb);
cout<<"tapez le nom du fournisseur";
getline(cin,nomf);
string insert_query = ""insert into bailleur (IDF,nomb, tel_b ,adresseb)
values (select IDF from fournisseur where nomf = '"+nomfou+"'
,'"+nomb+"','"+telb+"','"+adresseb+"')";;
const char* q = insert_query.c_str();
qstate1 = mysql_query(conn, q);
if (!qstate1)
{
cout << endl << "Successfully added in database." << endl;
}
ICYMI: 4TB Corsair MP700 PRO SE SSD is still selling at its lowest price by Fiza Ali
Amazon US and Newegg are still offering the 4TB Corsair MP700 PRO SE solid-state drive at its new lowest price. The MP700 PRO SE is an M.2 2280 SSD that employs a PCIe 5.0 ×4 interface with NVMe 2.0, delivering sequential read speeds of up to 14,000MB/s and sequential write speeds of up to 12,000MB/s.
It uses high-density 3D TLC NAND and carries a Total Bytes Written (TBW) rating of 3000. Furthermore, the drive can withstand vibration from 20Hz to 80Hz at 1.52mm and 80Hz to 2000Hz at 20G, as well as shocks up to 1500G. The drive incorporates AES 256-bit encryption and supports Microsoft DirectStorage, allowing compatible games to load assets directly to the GPU for reduced load times.
Moreover, it operates within a temperature range of 0°C to +70°C, and can be stored between –40°C and +85°C at up to 93% relative humidity (40 °C). A heatsink is not included, so users must provide their own or rely on a motherboard’s integrated SSD cooling solution to maintain optimal thermals.
Finally, the MP700 PRO SE is compatible with Windows 10, Windows 11, and macOS systems that provide an M.2 slot, and communicates via a standard M.2 2280 interface connector.
4TB Corsair MP700 PRO SE SSD: $549.99 (Amazon US) 12% off - $549.99 (Newegg) 9% off
This Amazon deal is US-specific and not available in other regions unless specified. If you don't like it or want to look at more options, check out the Amazon US deals page here.
Get Prime (SNAP), Prime Video, Audible Plus or Kindle / Music Unlimited. Free for 30 days.
You can also check out other SSD deals here. For hard disk drives, you can head over to our HDD deals section to see if anything from there matches your requirements. Make sure you also browse through Amazon US, Amazon UK, and Newegg US to find some other great tech deals. As an Amazon Associate, we earn from qualifying purchases.
"requiring individual licences from all rights-holders would impose an unmanageable administrative burden and could deter AI investment in the UK."
Ah so plebs (humans) will forever be required to secure license, but AI should get a broad pass because it's too complicated. Not so "intelligent" after all?
Plus, every opt out I have signed regarding Meta using my data was never presented to me in a clear way, I had to discover it here on neowin or some other news site with a link to do it. So what the government is saying is that they prefer to offer an opt out just to cover their asses, but good luck us plebs finding such a thing!
Question
niniben
I have a Table Bailleur
IDB IDF nameb Adresseb telb
----+------+------+---------------+-------
Where IDF is a foreign key to a table named Fournisseur
The Addresses Table:
IDF namef adressef telf
----+-------+----------+------+
This is a ONE-TO-N Relationship: Each Bailleur Has N fournisseur and each fournisseur has N bailleur
when i generated MPD I have a new table named fournir
IDF IDB
----+------
i want to insert data in "bailleur" by typing the name of founisseur which is namef and the IDF of "fournisseur" will be inserted into column IDF of table "bailleur" all this using c++
here is what ive tried i alredy inserted data in table "Fournisseur"
here im using bailleur in a class called bailleur
int qstate1;
MYSQL_ROW row1;
MYSQL_RES* res1;
void Bailleur::addb( MYSQL* conn){
string idf="";
cin.ignore(1, '\n');
cout << "Enter Nom du bailleur: ";
getline(cin, nomb);
cout << "Enter Adresse: ";
getline(cin, adresseb);
cout << "Enter tel : ";
getline(cin, telb);
cout<<"tapez le nom du fournisseur";
getline(cin,nomf);
string insert_query = ""insert into bailleur (IDF,nomb, tel_b ,adresseb)
values (select IDF from fournisseur where nomf = '"+nomfou+"'
,'"+nomb+"','"+telb+"','"+adresseb+"')";;
const char* q = insert_query.c_str();
qstate1 = mysql_query(conn, q);
if (!qstate1)
{
cout << endl << "Successfully added in database." << endl;
}
else
{
cout << "Query Execution Problem!" << mysql_errno(conn) << endl;
}
}
i expect output to be successfully added in database but its alway query execution problem
sorry for the long post this is my first time posting in neowin
Link to comment
https://www.neowin.net/forum/topic/1385153-how-to-insert-data-in-a-table-that-has-a-foreign-key-of-another-table-using-c-code/Share on other sites
0 answers to this question
Recommended Posts