Jump to content

mrmitch

Members
  • Posts

    18
  • Joined

  • Last visited

    Never

Everything posted by mrmitch

  1. HAHA - You have a knack for explaining things. As for greenie's problem - I still see no reason you'd want to do all that work when you can just have each record linked to the user responsible by their id or whatever you use to recognize them. This is a relational DB for a reason - to build relationships. You're going to have to make update scripts that run whenever these people log in, which takes more of their time, whenever you need to perform maintenance, or have a script that logs in as each user to update their db, taking time and resources. How many db's are we talking about anyway? Maintenance alone would be a bear.
  2. mrmitch

    Help

    Adding the carat before the group will search at the beginning of the movie name only, so the movie has to start with a number. REGEXP '^[0-9]%'
  3. $echo out your sql statements so you (we) can see the actual statement being sent to the db.
  4. So, rather than have one database and keying/linking all the rows with the unique user id, he creates and destroys similar databases for each user every time they log in/out. Interesting idea, but I'm with fenway - why?? You would have to be seriously cramped for database space in order to think this was a good idea. Query wise, MySQL is fast enough to work on extremely large databases, so there's no reason to worry about table size, in most cases. Security? There are better ways.
  5. What does the other query return? Try it with a MAX on timestamp and grouping by the user id. $GetAllSites = @mysql_query("SELECT userID, sitePref, MAX(timeStamp), valid FROM dental_emerg WHERE valid = 0 GROUP BY userID"); while ($GetAllSites2 = @mysql_fetch_array($GetAllSites)) { echo $GetAllSites2['timeStamp'] . "<br>"; } [\code]
  6. If you have a distinct person id per row, and they are ordered so that the person's latest entry is the highest id, you can select DISTINCT(person_id) from person order by id desc; It'll order the table by the latest entries and pull out the first row per id. Mitch
  7. After setting the NULL's to zero, you should give the column a default of 0. That'll stop it from ever having null values.
  8. Try and play with something like this to see if you can get the exact result set you're looking for. select a.name. a.site, count(b.member_id), group_concat(b.member_name SEPARATOR ',') from groups a left outer join members b on b.group_id = a.id group by a.id
  9. Wrote that backwards too - greater date goes first, so just reverse my logic in the previous post. DATEDIFF('2008-12-31',event_date_begin)>=0
  10. The lower date needs to go first to produce a positive result. I put > on both - sorry. begin date, beginning before '2008-12-31' is correct with the event_begn first, because it will be the earlier date. End date needs reversed, or the sign changed. Ending after '2008-12-01', so Dec 1st is always the earlier date. DATEDIFF('2008-12-01',event_date_end)>=0 Hope this helps! Mitch
  11. I'd do something similar to rhodesa, except the lookup table would be albumid, genre and genre would be an enum with your categories. You can have the album listed in there as id 1, genre Folk and again as id 1, genre rock.
  12. I think the first statement was close, but the second left join needed clarifying (if this will run in MySQL) SELECT players.playerID, players.playerFirstName, players.playerLastName, COUNT(games.playerID) as gamesplayed, COUNT(tries.playerID) as triesscored FROM players LEFT JOIN games ON players.playerID = games.playerID, players LEFT JOIN tries ON players.playerID = tries.playerID GROUP BY players.playerID
  13. Scratch that - Use DATEDIFF on Jan 1 2009 and Jan 31 2009 checking for >=0 and <=0 instead of the 2 betweens. DATEDIFF( event_date_end, '01-01-2008')>=0 (ends after jan 1) and DATEDIFF(event_date_begin,'01-31-2008')<=0 (begins before jan 31) This will find any date that begins before the end of the month AND ends after the beginning of the month. So beginning in November 2008 and ending in Jan 28 2009 (or Feb) matches because it begins before the end of January and ends after the beginning of January. Jan 2 - Jan5 begins before the end of the month and ends after the beginning of the month. This removes the need for the OR in your select too. Hope this helps! Mitch 3CG Developing (ask.3cgdeveloping.com) The between on your year is filtering everything out. It's looking for events that will start in 2008 and end in 2010 to find 2009 between.
  14. What happens when you run the query directly against the db? Switching to a left join will only pull out the left table, orders. It's not finding a match, so it's not displaying anything. If there is supposed to be a match, then you have a bigger problem. I'd also suggest using id's and not names on matching. Databases match integers much faster than strings.
  15. You could also use LOCATE()
  16. It may just be a simple syntax problem. Try parenthesizing (if that's a word) your and's from the or. SELECT event_id, event_date_begin, event_date_end FROM events WHERE ( (1 BETWEEN MONTH(k.event_date_begin) AND MONTH(event_date_end) ) AND ( 2009 BETWEEN YEAR(event_date_begin) AND YEAR(event_date_end) ) ) OR MONTH(event_date_begin) = 1 ORDER BY event_id ASC
  17. Using your formula, just move what you have for $X Select (sal_july / (sal_july - sal_june) ) as VAR_SAL from sal
  18. Just add in the INSTR() function to find the index of the @ symbol on each row. left(Email,INSTR(Email,'@')) same as doing INSTR(Email,'@') as index, left(Email, index) as EmailShort Mitch
×
×
  • 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.