mikosiko
Members-
Posts
1,327 -
Joined
-
Last visited
-
Days Won
1
Everything posted by mikosiko
-
I can't count these results coming from mysql!!
mikosiko replied to jeger003's topic in PHP Coding Help
I have not played with it but you can try with MYSQL REGEXP http://dev.mysql.com/doc/refman/5.1/en/regexp.html#operator_regexp -
I can't count these results coming from mysql!!
mikosiko replied to jeger003's topic in PHP Coding Help
try/adjust this... replacing "nvc_site_ads_extra.???" with the right column that join both tables $userISBNvalue = mysql_real_escape_string($_POST['szs']); $query_search_exact_match = mysql_query("SELECT nvc_site.title, nvc_site.id, nvc_site.description, nvc_site.search_text, nvc_site.image, nvc_site.date, nvc_site.price, nvc_site.location_city, nvc_site_ads_extra.name, nvc_site_ads_extra.value, nvc_site_ads_extra.classified_id FROM nvc_site_ads_extra JOIN nvc_site ON nvc_site.id = nvc_site_ads_extra.??? WHERE nvc_site_ads_extra.name = 'ISBN%3A' AND nvc_site_ads_extra.value = $userISBNvalue AND live=1") or die(mysql_error()); $num_rows = mysql_num_rows($result); if ($num_rows > 0) { echo "Match Found"; // Loop the resultset and do whatever you want with the data while ($fetch_extra = mysql_fetch_assoc($query_search_exact_match)) { // display the data or do what your need } } else { echo "No Match found"; } -
I can't count these results coming from mysql!!
mikosiko replied to jeger003's topic in PHP Coding Help
try this: change this line: while ($fetch_extra = mysql_fetch_array($query_search_exact_match)) for this while ($fetch_extra = mysql_fetch_assoc($query_search_exact_match)) in an additional note... I did notice that your query is doing a cross join between both tables (applying the filters that you have)... is that what you want?... or you want to join the matching records? -
try this SELECT students.student_id, students.last_name, students.first_name, students.grade_level, idtrack.event_id FROM students LEFT JOIN idtrack ON students.student_id = idtrack.student_id WHERE students.grade_level = 11 AND ( idtrack.student_id IS NULL OR idtrack.event_id=6) this is getting all the student with grade_level 11 who, are not present in the idtrack table or those with event_id = 6
-
John... if you read my answer again you will realize that I did'n say that your question was wrong... specifically I said "the sentence that you posted is wrong" ... big difference don't you think? and my additional comment was only pursuing more information to help you in the best way possible.... if in addition you just read the Sticky # 2 in this forum you will see that I was asking for basically the same things. your comments about my understanding or knowledge are totally uncalled for. for me is a closed issue.
-
the sentence that you posted is wrong... I saw also you other post... let me give you a suggestion that could help you to get answers... why you don explain exactly what you want to do (problem to solve), which are the tables involved and their structure ... only with that information people here will be able to understand your problem better and offer some insight... just MHO.
-
MySQL (on a Mac) Stored Procedures - Basic Question...
mikosiko replied to RIRedinPA's topic in MySQL Help
you can write it using the mysql command line or using a text editor and loading/running it or using any mysql administrative interface like phpmyadmin, mysqlQuery or Mysql Wokrwench (not sure if these works in MAC) -
try this... could be what you want .. I did include your table Product as you probably will like to display the Product name (query no tested) SELECT a.Attribute, pa.Product, pr.Product_Name FROM Attributes a LEFT JOIN Products_Attributes pa ON pa.attribute = a.id LEFT JOIN Products pr ON pr.product_id = pa.product WHERE pr.product_id ='1'
-
and a normalized one... good choice dgoosens
-
if you are asking me Fenway... in the solution that I did propose with an UNIQUE index across the customer UID the index is going to be duplicated. example: address_id customer_id Enum 1 1 NULL 2 1 'T' // address is billing 3 1 NULL // Duplicated unique index or you see another solution?..... after a bad night I'm to sleepy now to think clearly
-
EDITED: Just realize that the suggested procedure is not going to work my apologizes. This approach is close to a possible solution... "but AFAIK there's no way to ensure this is limited to a single address for any customer" why not?.... it is possible. What I will do is this: Add an additional attribute (column) to your ADDRESSES table with TYPE ENUM ALLOWING NULLS... per example: is_billing ENUM('T') DEFAULT NULL and then create an UNIQUE INDEX either on the column pair (address_id, is_billing) or (customer_id, is_billing)... that should solve the problem I think.
-
In the link that I gave to you are plenty of code example completely related to your problem should be really simple for you to figure it out just reading a few examples there
-
This approach is close to a possible solution... "but AFAIK there's no way to ensure this is limited to a single address for any customer" why not?.... it is possible. What I will do is this: Add an additional attribute (column) to your ADDRESSES table with TYPE ENUM ALLOWING NULLS... per example: is_billing ENUM('T') DEFAULT NULL and then create an UNIQUE INDEX either on the column pair (address_id, is_billing) or (customer_id, is_billing)... that should solve the problem I think.
-
The first thing that you should do is read in deep this http://dev.mysql.com/doc/refman/5.0/en/join.html after that the answer to your questions should be easy... just try
-
more likely SELECT DISTINCT DATE_FORMAT('%M',event_date) as month FROM table ORDER BY month
-
Anyone can help with this SIMPLE yet frustrating question
mikosiko replied to damiendarien's topic in PHP Coding Help
apparently because in this lines: $SQLstring = "SELECT * FROM $TableName"; if (!$QueryResult) { $QueryResult doesn't exist the second time that you execute your script, hence the if is always true. Seems that you need to execute the query that you defined in $SQLstring first and the ask for the value of $QueryResult, Independent of that... what are the reasons to have the CREATE DATABASE and CREATE TABLE in your code?.... you should create both only one time using PHPADMIN, MYSQL WORKWENCH or what ever mechanism that you prefer but I don see any reason to have that in your code. And in addition you should eliminate the @'s of your code... you are suppressing the display of errors instead of control if they occur. -
if you have a clear way to determine the user_id that you need to add in each line of your CSV file you can use the SET clause in the LOAD INFILE sentence to populate the field either as a calculated value or obtaining it with an scalar subquery... read the mysql manual for LOAD INFILE clause... specifically the part of the SET clause. hope this help
-
just a terminology fix first.... you are trying to compare 2 tables ... no 2 databases .. different concepts. try this (no tested but should work) $query = "SELECT a.brand, b.brand FROM brands a LEFT JOIN celebrities b ON a.brand = b.brand WHERE b.brand is NULL ORDER BY a.brand";
-
play with the TIMESTAMP() , TIMESTAMPADD() , TIMESTAMPDIFF(), UNIX_TIMESTAMP() and FROM_UNIXTIME() functions http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_timestamp
-
mysql migration toolkit even when has reached is EOL still available and works well http://dev.mysql.com/doc/migration-toolkit/en/
-
2 possible options: a) use the SUBSTRING() function directly in your sql query b) use the SUBSTR() function in PHP
-
I just clicked in the link and it works perfectly... curious
-
Is that your "REAL" database table?.... it doesn't looks very well designed or you posted incomplete information... in the way you are showing it you will have a lot of duplicated information ... for each student row you are going to have the classroom_location, class_count, school_count and district_count rows?... no good. (I'm not talking here of how you want to present your data... I'm talking about how you want to store it). And in addition, with that structure is not possible to resolve your questions. Seems that what you want to model is something more or less in this lines: - A District table (district_id, district_name) - A School Table (school_id, school_name, district_id) - A Classroom Table (classroom_id, classroom_location) - A Student Table (student_id, school_id, classroom_id, student_name) with a model like this you can solve your query easily using the student table.. hope this help... if not... post more complete information
-
is a not a syntax problem what you have there... just doesn't work in that way. "A stored function or trigger cannot modify a table that is already being used (for reading or writing) by the statement that invoked the function or trigger."