- Run the query directly in MySQL (e.g., via Workbench).
- Use a SELECT COUNT query to confirm the number of matching rows in the database.
Why is this SQLquery in Matlab returning repeated records?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I used JDBC driver to connect to the mySQL DB in Matlab. The connection works. However, when I used following SQLquery in Matlab to get data:
SQLquery = ['SELECT * FROM db_XYZ WHERE Col_Name=' '''Col_A'''];
I got repeated (always three times) results shown as below:
1 Col_A CA SFO 1 Col_A CA SFO 1 Col_A Ca SFO
There is only row of "1 Col_A Ca SFO" in the database table.
Why? Thanks...
0 Kommentare
Antworten (1)
colordepth
am 12 Mär. 2025
Bearbeitet: colordepth
am 12 Mär. 2025
The query syntax appears to be correct. Start by inspecting the MATLAB result structure to confirm the number of rows returned by MATLAB:
disp(size(fetchedData))
If it shows duplicates (e.g., 3 rows), proceed to validate the database:
If the database returns 1 row but MATLAB shows duplicates, the issue is not database-level. This indicates MATLAB is appending results (e.g., repeated fetch calls or code logic like loops). If both the database and MATLAB show duplicates, check for triggers using:
SHOW TRIGGERS FROM your_database;
0 Kommentare
Siehe auch
Kategorien
Mehr zu Verify Generated Code and Deployed Code Artifacts finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!