bubblegum.anarchy
Members-
Posts
526 -
Joined
-
Last visited
Never
Everything posted by bubblegum.anarchy
-
example: id => 1 reaID => '1;2;3;4;2' id => 2 reaID => '1;3;2' the result for reaID = 2 would be: id reaID_count 1 2 2 1 correct ?
-
To get all work recods with associated user records: SELECT work.work_id , input_user.* , worker_user.* FROM work INNER JOIN user AS input_user ON input_user_id = input_user.user_id INNER JOIN user AS worker_user ON worker_user_id = worker_user.user_id ;
-
you can always do SELECT company.id AS company_id FROM company and then $row['company_id']
-
[SOLVED] Combine data from two tables in a [while] loop
bubblegum.anarchy replied to patrickm's topic in MySQL Help
Use an inner join to return only all record in table 2 that have a matching table 1 id. -
[SOLVED] Trigger Saviour or Still Can't Do Simple Task
bubblegum.anarchy replied to grrraaagh's topic in MySQL Help
The calculation can be done in the select query as so: SELECT standings.*, w*3 + pts AS calc FROM standings ORDER BY pts desc, w desc -
[SOLVED] SELECT particular disctinct row based on date
bubblegum.anarchy replied to infinets's topic in MySQL Help
oh yes, that is great Barand... and ORDER BY pay_date DESC -
[SOLVED] SELECT particular disctinct row based on date
bubblegum.anarchy replied to infinets's topic in MySQL Help
The following code looks all kinds or wrong to me even through the results appear correct: SELECT * FROM ( SELECT * FROM park ORDER BY pay_date DESC ) AS derived GROUP BY id ORDER BY pay_date DESC; -
Perform your own error handling.
-
[SOLVED] Trigger Saviour or Still Can't Do Simple Task
bubblegum.anarchy replied to grrraaagh's topic in MySQL Help
When do you want the calculation to occur? -
This is the way I usually check for duplicates: $result = mysql_query("INSERT INTO temp SET content = 'variance'") or mysql_errno() == 1062 or tigger_error(mysql_error(), E_USER_ERROR); if (mysql_errno() == 1062) // handle duplicate ... else ...
-
Protecting From MySQL Injection Attacks
bubblegum.anarchy replied to Liquid Fire's topic in MySQL Help
I am not sure what the best way is but this is what I do: return "'".(get_magic_quotes_gpc() ? mysql_real_escape_string(stripslashes($value)) : mysql_real_escape_string($value))."'" -
You are still probably going to have to poll for changes... keep a simple unix_timestamp field since last change.
-
WHERE TRUE OR TRUE OR TRUE => will return TRUE WHERE TRUE OR TRUE OR FALSE => will return TRUE WHERE TRUE OR FALSE OR FALSE => will return TRUE and even WHERE FALSE OR FALSE OR TRUE => will return TRUE hence... the return value will be TRUE when at least one of the conditions is TRUE Consider reading up on basic conditional logic.
-
I got the following information from the mysql website: http://dev.mysql.com/doc/refman/5.1/en/xml-functions.html#function_extractvalue
-
Concatinating all the conditions with AND means that all conditions must be TRUE for the record to be returned, use OR instead to return the records where only one condition is TRUE... WHERE first = '1st' AND second = '2nd' AND third = '4rd' => WHERE TRUE AND TRUE AND FALSE => will not return the record because not all conditions are TRUE on the other hand.. WHERE first = '2st' OR second = '1nd' OR third = '3rd' => WHERE FALSE OR FALSE OR FALSE => will return the record because at least one of the conditions is TRUE.
-
[SOLVED] Something wrong with my syntax!?
bubblegum.anarchy replied to bobleny's topic in MySQL Help
MySQL is interpretting the backtick quoted signup string as a table name rather than a string... wrap insert strings with single quotes. -
I am not sure inserting into more than one table at a time with the one query is possible.. EDIT just use two queries... how else are you going to link the members_address without an auto increment id of the members_info?
-
Here is a site that details what a unix timestamp is: http://www.unixtimestamp.com/ Simply put a unix time is the amount of seconds since an epoch (a particular point in time), the epoch is defined by the unix system is 1970-01-01 00:00:00, so the a function call to unix_timestamp() return the number of seconds that has passed since 1970-01-01 00:00:00. The unix timestamp is an effective way to sort dates.
-
I am not so sure the query you posted provides the correct records - lets get other opinions.
-
`AS derived` is an alias for the resulting recordset produced via this `(SELECT * FROM temp ORDER BY lastdate DESC)` - you can have AS any_alias_name_u_like_that_is_not_a_reserved_word
-
so what you actually want is simply this: SELECT * FROM (SELECT * FROM temp ORDER BY lastdate DESC) AS derived GROUP BY id; and you will find that DanDaBeginner was right in the first place when suggesting my initial query was erroneous
-
I am not sure what you mean and you haven't answered my original questions dabip... your answers will help me better understand what you are trying to achieve. DanDaBeginner - what do you think of this query? - might be just what dabip needs. SELECT * FROM (SELECT * FROM temp ORDER BY id, lastdate DESC) AS derived GROUP BY id;
-
saying that you only want rows where the id2 = 0 means that you want a WHERE id2 = 0 in your query... correct me if I am wrong but does not max(id2) = the most recently post in a thread ? so for each unique id you want the record with the max(id2) or for each unique id you want the record with the most recent lastdate right?
-
You are right DanDaBeginner, my original query is all wrong... just happened to work.