mikosiko
Members-
Posts
1,327 -
Joined
-
Last visited
-
Days Won
1
Everything posted by mikosiko
-
that is ok.... if you like it and works for you .... me... being more a SQL type of guy I'll not solve it like that not even in my worst nightmare ... I'm imagining how that select will look if you receive an array with 50 or more elements to test..... 50 or more INNER JOINS and your where clause with 50 or more AND's.... but... as I said... as long as it works for you glad to try to help.. good luck
-
...yes that could work too...... I'm not sure... how your select solve this: (if your first sentence was correct) are you going to modify you select every time?....
-
so I was right... and you are not looking for an INTERSECT... you are after a RELATIONAL DIVISION... couple links where you can read about: http://www.simple-talk.com/sql/t-sql-programming/divided-we-stand-the-sql-of-relational-division/ http://www.tc.umn.edu/~hause011/code/SQLexample.txt here is an example that should solve your query: SELECT DISTINCT a.songs_id AS sngid FROM songs_x_keywords AS a WHERE NOT EXISTS (SELECT b.keywords_id FROM vkeywordsid AS b WHERE b.keywords_id NOT IN (SELECT c.keywords_id FROM songs_x_keywords AS c WHERE c.songs_id = a.songs_id)); the trick.... to do this you must create a table (vkeywordsid) with the values that you get in your array of keywords_id... try it... I did test the code with your example data at it works... it return songs_id's 1 & 2.
-
now I don't follow... then you are not talking about INTERSECT ... because song_id # 3 is not in the keywords_id group #5... or I understood you incorrectly?...
-
what???... I'm lost kind of lost with those 2 sentences... echo your $username variable and check if the value will be consistent with your SELECT and what Pikachu2000 suggested is also valid.
-
New set of eyes on my Query - UPDATE, SET 2 Tables
mikosiko replied to OldWest's topic in MySQL Help
it is good... that is the way to do it.... just one observation based on your description: you want to do the update ONLY if the locations_all.state_id is blank (empty, null or 0.. depending of the data type)... or you want to update it always? If the first case you need a condition (WHERE clause) in that UPDATE ... otherwise you are good to go -
well... you first source should be: http://dev.mysql.com/doc/refman/5.0/en/update.html there are some examples... and also you can follow the links on that page and you should be able to figure out how to do it.... and the easy... "instant gratification" way UPDATE table1 t1 JOIN table2 t2 ON t1.id = t2.id SET t1.col1 = t2.col2, t1.col2 = t2.col2
-
post your code
-
How to say it (select ... from where .... and ...)
mikosiko replied to egturnkey's topic in PHP Coding Help
read: http://dev.mysql.com/doc/refman/5.0/en/problems-with-null.html -
All depend of in which context you saw it.... could have multiples meanings... one is what Pikachu2000 mentioned.
-
did you check that you are using the right path and that you have access to that file? In your position I will modify your code a bit in this way (partial code) /*** File to Load ***/ $file = '/public_html/admin/files/test-jp-stock.csv'; if (!is_readable($file)) { echo "Error : File '$file' doesn't exist or is unreadable"; exit(); } // Build SQL Query $query = "LOAD DATA INFILE '$file' INTO TABLE jpaero_stocksearch FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' IGNORE 1 LINES"; // Notice that here you should not use ' around your table name mysql_query($query) or die("Error in Query : " . $query . "<br />Error Code = " . mysql_error() . "<br /> Upload Failed... Contact Support"); echo ">> New Stock Data has now been uploaded. Database is now live and searchable.";
-
NO!! you need indexes in your LOCATION TABLE one index for LOC_ROW column and one index for LOC_COLUMN column... and one more time: read http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html
-
I bet that you didn't read this question in my last post: (table location) I don't see in the CREATE TABLE LOCATION that was originally posted any INDEX definition. please read: http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html
-
Did you check that both INT columns in both tables have exactly the same sign also? also... are both tables are using the Innodb engine? are the columns indexed ? you can also use SHOW ENGINE INNODB STATUS to display a detailed explanation of the most recent InnoDB foreign key error in the server. here also you can read all the neccesary to detect any condition that could be causing that error. http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html
-
in your table LOCATION... You are declaring the columns LOC_ROW and LOC_COLUMN has NOT NULL , however in your table SHOE doesn't have the same definition.... make them equals.
-
why not? try: SELECT a.dept AS Department, b.firstname AS MgrFName, b.surname AS MgrSName, c.firstname AS DptyFName, c.surname AS DptySName FROM departments AS a JOIN employees AS b ON a.manager = b.payroll JOIN employees AS c ON a.deputy = c.payroll
-
same ... just with one table.... however... what Dan is suggesting in term of using 2 tables is the right way that you should design your DB
-
You have problems with the names of your fields... this should be the right ones // Field Mapping $sFirstName = $_POST['FirstName']; $sLastName = $_POST['LastName']; $sHomeCity = $_POST['HomeCity']; $sHomeState = $_POST['HomeState']; $sCountry = $_POST['selCountry']; $sHotel = $_POST['txtHotel']; $sCity = $_POST['txtCity']; $sState = $_POST['selState']; $sStayLength = $_POST['StayLength']; $sHowHelpful = $_POST['HowHelpful']; $sImprovements = $_POST['Improvements']; check them and try
-
because more likely your query is incorrect and not producing the results that you expect. suggestions: - Add the 2 lines in my signature at the beginning of your code after your "<?php" tag... it will help you to deal with errors more easily. - Change at least this line $result = mysql_query($sql); to this: $result = mysql_query($sql) or die("Query : " . $sql . " Error : " . mysql_error()); this will allow you to see the real final query that you are sending to the DB and also to display any error if the sentence is incorrect.. stopping the code if something goes wrong.
-
is that your complete form code ?...
-
posted code doesn't have line 160.... something is not adding up
-
Get the id of the fields updated by an update query?
mikosiko replied to themistral's topic in MySQL Help
No -
How pass empty or nothing to a default parameter for a function?
mikosiko replied to someguy321's topic in PHP Coding Help
Examples #3 and #4... pay special attention to note before example #5 and then #6 http://php.net/manual/en/functions.arguments.php -
You can do a couple things: 1) add the 2 lines in my signature at the beginning of your code... that could help you to detect you errors. 2) remove all those "@'s" from your code... and never use them... they only hide your code errors... not good. 3) at least add die("error : " . mysql_error());" after your connect and fetch sentence to detect/control errors. your error is most likely because you are not connecting to your DB and you are not seeing the error because the @'s try/test and let us know
-
That is impossible if your process is updating just one row... the trigger is going to act only over the affected row(s) in whatever update that you are executing... check your update not the trigger. the syntax that you showed in the second time is incorrect.. first one was close ...just modify it slightly and pay attention to the DELIMITER when you create it (maybe that was the error in your first intent): CREATE TRIGGER pHash BEFORE UPDATE ON products FOR EACH ROW BEGIN SET NEW.model_hash = crc32(NEW.products_model); END