salami1_1 Posted December 5, 2008 Share Posted December 5, 2008 Hi Guys, I'm working on MySql version: MySQL client version: 4.1.22 Query: SELECT logindb.aantallogs, orderdb.sell_price,orderdb.sell_curr FROM ics_orders orderdb, ics_logins logindb WHERE logindb.product_link = orderdb.id AND gebruikt = 1 ORDER BY logindb.aantallogs ASC Table layout: CREATE TABLE ics_logins ( id SMALLINT UNSIGNED NOT NULL auto_increment, username VARCHAR(40) NOT NULL, pass VARCHAR(40) NOT NULL, aantallogs SMALLINT NOT NULL, gebruikt TINYINT UNSIGNED DEFAULT '0' NOT NULL, type char(15), product_link CHAR(20) NOT NULL, orderlink INT UNSIGNED, PRIMARY KEY (id) ); ALTER TABLE ics_logins ADD INDEX icsLogin_index (username,aantallogs,gebruikt,product_link); #product_link is the unique product_name from product db #orderlink is id from ics_orders (1 to many) CREATE TABLE ics_orders ( id INT UNSIGNED NOT NULL auto_increment, selldatum CHAR(16), cust_email VARCHAR(60) NOT NULL, payp_orderid CHAR(25), cust_name char(100), cust_ip CHAR(16), cust_country CHAR(5), sell_price FLOAT(7,2) NOT NULL, sell_curr CHAR(10) NOT NULL, affiliate char(40), note text, PRIMARY KEY (id) ); ALTER TABLE ics_orders ADD INDEX icsOrders_index (cust_email,cust_country,sell_curr,affiliate); Now in the order table there are 2 currencies EUR and USD (mostly EUR just couple USD) but with the query I only get the results with EUR and not USD.. I checked if perhaps the linking was wrong (mysql doesn't support foreign key so that is not defined in create table statements) but that is all fine. I'm probably doing something wrong but I even took my last semester database design lectures with it but couldn't find the mistake.. If anybody can point me in the right direction? Thanks. Best regards, Quote Link to comment https://forums.phpfreaks.com/topic/135634-solved-query-not-given-what-i-want/ Share on other sites More sharing options...
Mchl Posted December 5, 2008 Share Posted December 5, 2008 Could it be, that gebruikt = 1 only where currency is EUR? Other than that I can not see anything that would limit the query. And yes, MySQL does support foreign keys since ver. 3.22.34 edit Why are you using logindb.product_link = orderdb.id instead of logindb.orderlink = orderdb.id ? Quote Link to comment https://forums.phpfreaks.com/topic/135634-solved-query-not-given-what-i-want/#findComment-706659 Share on other sites More sharing options...
BloodyMind Posted December 5, 2008 Share Posted December 5, 2008 Could it be, that gebruikt = 1 only where currency is EUR? Other than that I can not see anything that would limit the query. And yes, MySQL does support foreign keys since ver. 3.22.34 edit Why are you using logindb.product_link = orderdb.id instead of logindb.orderlink = orderdb.id ? Indeed just use InnoDB Engine so it supports transactions Quote Link to comment https://forums.phpfreaks.com/topic/135634-solved-query-not-given-what-i-want/#findComment-706815 Share on other sites More sharing options...
Mchl Posted December 5, 2008 Share Posted December 5, 2008 Foreign keys and transactions are two veru different things, but yes InnoDB supports both. Quote Link to comment https://forums.phpfreaks.com/topic/135634-solved-query-not-given-what-i-want/#findComment-706821 Share on other sites More sharing options...
salami1_1 Posted December 6, 2008 Author Share Posted December 6, 2008 Aaaah thanks! I was using the wrong Fk constraint indeed! Changing product_link with orderlink did the trick! Are you sure Mysql supports Fk? Maybe they can disable that on public hostings? Because tried with; CREATE TABLE ics_newsreactions ( id SMALLINT UNSIGNED NOT NULL auto_increment, postlinkid SMALLINT UNSIGNED NOT NULL, bericht text NOT NULL, datum CHAR(35) NOT NULL, poster_naam CHAR(20) NOT NULL, poster_email VARCHAR(30) NOT NULL, posterip CHAR(16) NOT NULL, active TINYINT(1) UNSIGNED NOT NULL, seckey CHAR(20) NOT NULL, PRIMARY KEY (id) #FOREIGN KEY (postlinkid) REFERENCES ics_news(id); ); (complete other table) but it gave me errors with the foreign key (so commented out now) I'm not using Inno because Inno does not support index and as I'm on shared hosting I need all the efficiency I can get. Best regards, Quote Link to comment https://forums.phpfreaks.com/topic/135634-solved-query-not-given-what-i-want/#findComment-707345 Share on other sites More sharing options...
corbin Posted December 6, 2008 Share Posted December 6, 2008 Foreign keys and transactions are two veru different things, but yes InnoDB supports both. I think he was referring to the little thing that MyISAM does not support foreign keys. (Last I checked, anyway.) Quote Link to comment https://forums.phpfreaks.com/topic/135634-solved-query-not-given-what-i-want/#findComment-707392 Share on other sites More sharing options...
salami1_1 Posted December 6, 2008 Author Share Posted December 6, 2008 I think he was referring to the little thing that MyISAM does not support foreign keys. (Last I checked, anyway.) yeah correct, I know its not true but I see InnoDB as a different think as when I say Mysql, as MyIsam is standard. Quote Link to comment https://forums.phpfreaks.com/topic/135634-solved-query-not-given-what-i-want/#findComment-707475 Share on other sites More sharing options...
Mchl Posted December 6, 2008 Share Posted December 6, 2008 I'm not using Inno because Inno does not support index Who told you that? Quote Link to comment https://forums.phpfreaks.com/topic/135634-solved-query-not-given-what-i-want/#findComment-707478 Share on other sites More sharing options...
ashishag67 Posted December 6, 2008 Share Posted December 6, 2008 hey salami1_1 creating database is a pain in a neck if done with coding I would suggest use phpmyadmin... it comes with a bundle in wampserver which consist of apache, php , mysql, postgre this will solve your problems with foreign key as well.. check this website: http://www.mysqlandphp.net Quote Link to comment https://forums.phpfreaks.com/topic/135634-solved-query-not-given-what-i-want/#findComment-707487 Share on other sites More sharing options...
salami1_1 Posted December 7, 2008 Author Share Posted December 7, 2008 I'm not using Inno because Inno does not support index Who told you that? Its not true then? Don't remember exactly where I got that from but read it somewhere.. If its not true then why is the MyIsam always standard? Because in that case it looks like InnoDB is better in every way @ashishag67 yes I also use phpmyAdmin but its not a full solution. PHPmyadmin is not a solution to design databases more for maintaining them. Quote Link to comment https://forums.phpfreaks.com/topic/135634-solved-query-not-given-what-i-want/#findComment-708277 Share on other sites More sharing options...
Mchl Posted December 7, 2008 Share Posted December 7, 2008 For many MySQL versions InnoDB was in fact inferior to MyISAM in terms of performance. Nowadays however they go head to head, with InnoDB often having an edge, where amount of queries is not very high. MyISAM is still a better choice, when you have a lot (like hundreds per second) SELECT queries, and a lot less INSERT and UPDATE queries. Also some shared hosts don't like InnoDB, as it requires more memory (so guess what? thay can have less clients on same hardware!) Actually InnoDB has been set as a default storage engine for Windows installations (since somewhere in 5.0 I suppose). Quote Link to comment https://forums.phpfreaks.com/topic/135634-solved-query-not-given-what-i-want/#findComment-708401 Share on other sites More sharing options...
salami1_1 Posted December 10, 2008 Author Share Posted December 10, 2008 For many MySQL versions InnoDB was in fact inferior to MyISAM in terms of performance. Nowadays however they go head to head, with InnoDB often having an edge, where amount of queries is not very high. MyISAM is still a better choice, when you have a lot (like hundreds per second) SELECT queries, and a lot less INSERT and UPDATE queries. Also some shared hosts don't like InnoDB, as it requires more memory (so guess what? thay can have less clients on same hardware!) Actually InnoDB has been set as a default storage engine for Windows installations (since somewhere in 5.0 I suppose). thanks for the explanation, maybe I should switch my stuff to InnoDB then.. I'll have a closer look at that when I have the time. Thanks for the help! Quote Link to comment https://forums.phpfreaks.com/topic/135634-solved-query-not-given-what-i-want/#findComment-711247 Share on other sites More sharing options...
Mchl Posted December 10, 2008 Share Posted December 10, 2008 Just make sure, your host supports it. I was dismayed recently, when I found out my newly bought hosting account has no InnoDB support (and will not have, whatever I do - unless I buy dedicated server with them) Quote Link to comment https://forums.phpfreaks.com/topic/135634-solved-query-not-given-what-i-want/#findComment-711249 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.