Jump to content

mikosiko

Members
  • Posts

    1,327
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by mikosiko

  1. mikosiko

    Join help

    it is ok... I found the reason reading the "small prints" in the manual Reserved words are permitted as identifiers if you quote them as described in Section 8.2, “Schema Object Names{/b]”: mysql> CREATE TABLE interval (begin INT, end INT); ERROR 1064 (42000): You have an error in your SQL syntax ... near 'interval (begin INT, end INT)' mysql> CREATE TABLE `interval` (begin INT, end INT); Query OK, 0 rows affected (0.01 sec) Exception: A word that follows a period in a qualified name must be an identifier, so it need not be quoted even if it is reserved
  2. I was referring exactly to this: "I also had to add a fourth column to free up keyword_id to permit duplicate entries. So that fourth column is now the primary key." not sure why you need those 2 columns... to me seems logical to have only one... the auto-generated Id | keyword_id | keyword | product_id and BTW... I'm asking because I believe that you code could be improved... but of course you can be happy with what you have already
  3. mikosiko

    Join help

    Humm... interesting.... what Mysql version are you using?.... asking because at least starting with version 5.0 the words "long", and "primary" are reserved words (the word "type" is not.. that was my mistake)... good to know that it works for you. and BTW: my apologizes for the reference to the JOIN syntax... I'm so used to the long version that I forgot completely about the short one.
  4. why are you using 2 id's for the table keywords?... doesn't make sense to me... but of course I can be wrong understanding that part of your objectives.
  5. I'm kind of lost... for better help, could you explain what exactly are you trying to do... seems to me that: (correct me if I understood incorrectly) - You are capturing products and associated information. - Part of that additional information seems to be a series of "keywords" that in some way could help to describe that specific product - Next you want to create the record in the table product and along with that also insert all the "keywords" associated to that product in the table "keywords" Did I understand your objective correctly?
  6. @samtWilliams: I can't offer help here but maybe this apply in your case... taken from the class description "Once the connection is opened, it can send data to the serial port, and read answers (reading is only implemented for linux). The class may also change connection parameters for the given serial device. ==> /!\ WARNING /!\ : it's working with linux for r/w, but with windows i've only been able to make write working. If you're a windows user, try to access the serial port through network with serproxy instead."
  7. mikosiko

    Join help

    First... you should read a little more about JOIN's syntax ... here... now... as an example, here is what apparently you were trying to write: "SELECT co.title, co.f_name, co.l_name, cu.reference, cu.created_by_id, cu.created_date, p.addr1, p.addr2, p.town, p.city, p.county, p.postcode, p.country_id, p.`long`, p.lat, p.`primary`, ci.info, t.`type` FROM customer cu, JOIN contacts AS co ON co.customer_id = cu.customer_id JOIN contact_info AS ci ON ci.contact_id = co.contact_id JOIN premesis AS p ON p.customer_id = cu.customer_id JOIN `type` AS t ON t.type_id = ci.type_id WHERE cu.customer_id = $cust_id LIMIT 1" Some suggestions: - Don't use unnecessary " - Notice how I did enclose some fields/table names in backtics (`) that was neccesary because you are using MYSQl reserved words, the best option, if that still possible, is to change the fields/table names to something that is not a reserved word, otherwise you must use the backtics every time in your application for those fields/tables.
  8. SELECT `Start Date`, `End Date` FROM table1, table2 WHERE table1.iframe_id = table2.course_id which is equivalent to SELECT `Start Date`, `End Date` FROM table1 JOIN table2 ON table1.iframe_id = table2.course_id also if you really have the columns named like that, including spaces you must enclose them in backtics, but is much better if you don't use spaces in then names.
  9. something is no matching here.... In your first post you said that your tables layouts were like this: table one ID Title Course content table two has ID Title Start date End date and in your last post you said that the layouts are this table one ID Title Course i_frame table two has ID Start date End date course_id and you want to join by "title" .... ??? which one is your correct table layout?
  10. "WHAT" (error_reporting) and "WHERE/WHEN" (display_errors) are not the same... but obviously if "WHAT" is "nothing"... "WHERE/WHEN" doesn't make sense and looks like the same further reading http://www.php.net/manual/en/errorfunc.configuration.php#ini.error-reporting
  11. You should do this: - Post some of the data in your table ... real data. - Post an example of what is the expect result don't post any code... just the data and the results that you want... sure someone will chime with a solution.
  12. You are wise to ask these questions now, before you proceed further your database; in the long term it will save you a lot of troubles. A good start is to read as much as you can about Relational Databases (RDB) and how they operate; in escense they are efficient and flexibly as they do ONLY because they are based on strict mathematical set theory, developed by an IBM mathematician, Dr. Codd around 1970. A RDB impose a set of formal rules that you should apply to reach the correct way (according to the RDB theory) to structure your tables; they are called the "Normal Forms", beginning with First Normal Form (1NF), Second Normal Form (2NF), and Third Normal Form (3NF). The main goal of the Database design is to meets the first 3 Normal Forms, and you will be assured of a solid structure, flexible for most likely every purpose. You can find many references online (search for database normal form). One of the requirements to meet 1NF is that every column (field) should be "atomic" or single-valued; that is, it should not be possible to divide the value into several components. That's the reason you should not ordinarily store first and last names in the same field or list like the one that you are using. It makes it awkward or sometimes impossible to do searches on components of a field, for example. Another search you can do for help: data modeling. Hope this give you a good help and a point to start and model your DB better.
  13. @Steve: One feature that could be of interest for you also is the usage of a TIMESTAMP field with DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP properties enabled, that allow you to eliminate the UPDATE part of the previous posted code because in that case the update of that field is automatic. more information and examples here
  14. if try to help you means "be a dick".... then you really are having a bad day... if as you say .. you use JOINs everyday then explain which is the difference between this sentences: // your second one SELECT a.eventtype_id, b.organisation_id FROM events_lu_eventtypes AS a JOIN organisations AS b ON 1=1 // and this one SELECT e.eventtype_id, o.organisation_id FROM events_lu_eventtypes as e, organisations as o WHERE 1 = 1 if you "work everyday with JOIN's" as you said you probably should know as the three of them are EXACTLY THE SAME... so whom is the "dick'? post/help closed in my side... hope your day improve.
  15. which is totally incorrect and will give you wrong results. you should read a little about how JOIN's in general work.
  16. you need at least a JOIN here SELECT e.eventtype_id, o.organisation_id FROM events_lu_eventtypes as e, organisations as o
  17. an almost identical issue was discussed [urlhttp://www.phpfreaks.com/forums/index.php?topic=332585.msg1566172#msg1566172]here[/url] ... pay close attention to PFMaBiSmAd answer and suggestion regarding to the table structure
  18. one option: (assuming that you can have only 1 "substring" into your 'string') $data = 'Hello World "This is a test string! Jack and Jill went up the hill."'; preg_match_all('/\".*\"/', $data, $matches); echo "<br /> There are " . substr_count($matches[0][0], ' ') . " spaces"; you should incorporate code to validate in case your 'string' doesn't include a "substring"
  19. http://dev.mysql.com/doc/refman/5.5/en/regexp.html lot of examples there
  20. mikosiko

    query

    Don't .... just store the images in a folder(s) in your server and in your table define a field (VARCHAR) to store the PATH to the image.
  21. you better read here and here... just saying
  22. then use preg_match() , validate result and discard the record accordingly.
  23. a quick/dirty solution: don't do anything in your select... just get the recordset and pos-process it in php... in your case something like this: $badwords = array('/ bad1 /', '/ bad2 /', '/ bad3 /'); // this is the array of your bad-words ... could be a separate file for better maintenance $replace_with = ' ***** '; // if you need to write something instead of the bad-words. $strQuery = "SELECT * FROM $table ORDER BY dtAdded DESC"; // replace $table with your table name $queryGetComments = mysql_query($strQuery) or die(mysql_error()); // add any validation that you need while ($row = mysql_fetch_assoc($queryGetComments) { // anything you need here... echo preg_replace($badwords, $replace_with , $row['comment-column']); // replace 'comment-column' with your comment column.. using echo only for testing purposes. }
  24. you must show what have you tried already.... if you don't know where to start here is a couple hints: JOIN SUM put some effort studying the examples, write some code, and come here with specific questions/doubts and sure someone will help.
  25. you'r wise to be worried about doing multiples queries in a loop... that normally call for an application review. answering you question: afaik, that is not possible using sql over it again, you probably could store the result set in an array and post-process it using php functionality... but my best suggestion for you is to post the code that you have to see if it can be optimized first.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.