Jump to content
Larry Ullman's Book Forums

goingcrazy

Members
  • Posts

    6
  • Joined

  • Last visited

goingcrazy's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. nope, product_number 1 in store A and product_number 1 in Store B are different products, and they have different product_id's, I know its confusing, I'm a rookie poster and need to learn to be clearer
  2. a product_id can only exist in one store, store A can have product_number =1, and store B can have product_number = 1, but never the same product_id., thanks for the little cd analogy.
  3. thanks Matthaus, that makes sense. I've already changed the name of my table, and again reviewed mysql list of keywords to avoid. thanks for the help. Barrett
  4. INSERT INTO `values` VALUES (NULL, (SELECT product_id FROM products WHERE product_number = $prodNum AND store_id = $storeID), $value, '$datetime'); ANSWER1: I have a basic understanding of the NULL value, question is what is it doing in the above example query? Why not write the query like this: INSERT INTO 'values' VALUES (SELECT product_id FROM products WHERE product_number = $prodNum AND store_id = $storeID), $value, '$datetime') ANSWER2: There are no examples of a query written like this in PHP 6 and MYSQL 5, 3rd edition, an INSERT with a SELECT section inside it? I was wondering where the information or direction came from on how to write it. thanks, Barrett
  5. Table Relationship: stores have multiple products, and each product has a value that changes with time, every minute. The value is not a sale price, but a chemical composition value. I think you have what I was looking for. To do the INSERT into the values table I need the product_id, but I don't have it unless I write a seperate SELECT query to get it (and I didn't want to do that, but yes, I could). The product_id is the primary key in the products table, and combined product_number and store_id are unique. Your INSERT query is a form I am not familiar with; an INSERT query with a little SELECT section in it? Question: What does the NULL value represent, is that for if the SELECT query fails and does not return a product_id from products table, a NULL value gets inserted? Question: I didn't find this in Larry's Book, PHP 6 and MYSQL 5, 3rd Edition, is there a web reference I could read? Thanks, Barrett
  6. a bit confused with how to properly use Joins. This may not even be possible. my database structure table_name(column_1, column2, column3), underlined is primary key, *foreign key stores(store_id, store_name) products(product_id, *store_id, product_number, product_name) values(value_id, *product_id, value, datetime) Question: Can I write an INSERT query for the values table knowing the following: value, datetime, store_id, product_number? Or do I first have to do a select query to grab the correct product_id from the products table? NOTE: I didn't have these questions when I had a sloppy database design, lol, I'm trying. Thanks for the help. Barrett
×
×
  • Create New...