Posts Topics Forums Images
Search videos from message boards Videos Search messages from microblogs Microblogs Search messages from imdb.com Imdb Search messages from yuku.com Yuku Search messages from lefora.com (free forums) Lefora
My account: Login | Sign Up
Loading... 

Thread: MAX() in WHERE clause

Started 3 weeks, 6 days ago by smmairaj
Hi, I am going crazy with a problem and would really appreciate if anybody could help me with it!! Here is what I am trying to achieve: I have two tables - "tickets" and "ticket_updates" tickets has following columns: TicketId, UserId, AssignedToId, ... DateCreated, Status ticket_updates has following columns: UpdateId, TicketId, UpdaterId, ... DateUpdated I am...
Site: dBforums - Database Support Community  dBforums - Database Support Community - site profile
Forum: MySQL  MySQL - forum profile
Total authors: 94 authors
Total thread posts: 11 posts
Thread activity: 44 new posts during last week
Domain info for: dbforums.com

Other posts in this thread:

ozzii replied 3 months, 1 week ago
Quote: Originally Posted by r937 that's the right conclusion, but the logic is slightly off if the company does not need to have an image, then the image columns are ~not~ mandatory as for best practice, what do you do if a company needs to be registered but it does not have a fax number? Yes I see your point. But an ...

zed420 replied 3 months, 1 week ago
Thank you sir I saw your post of timeline in a different forum and managed to sort it. That was a great help it's been a week I've been at this query. Thanks Zed

gvee replied 3 months, 1 week ago
If the view consists of more than one table then you will not be able to insert in to it. Instead you must construct a separate insert statement per table that you wish to populate.

wizardry replied 3 months, 1 week ago
the view consists of one table. i understand the rules of views. its that im using aes_encrypt in the creation of the view, and it doesnt encrypt the data it errors. Ive created a test view with out the aes_encrypt in the view and it inserts fine no prob. what i would like is to use aes_encrypt in the view not the insert statement. less overhead on app. i've used aes_decrypt ...

blindman replied 3 months, 1 week ago
Apparently there was no way to do this, so we ended up moving the entire database. On Windows: 1) Stop the MySQL service 2) Move the data folder from X:\OriginalLocation\data\ to Y:\NewLocation\data\ 3) Add this line to my.ini datadir=Y:\NewLocation\data\ 4) Restart the MySQL service

aflorin27 replied 3 months, 1 week ago
As you need only YOUR relationships, the WHERE clause should look like: WHERE uc.UserContactsID = 1234 AND myCharity.userID = your_ID

r937 replied 3 months, 1 week ago
i'm not sure i used the correct columns (see below) but the structure of the query you need involves a LEFT OUTER JOIN for the specific charity Code: SELECT c.charityID , c.charityName , myCharity.relationshipType FROM UserContacts uc INNER JOIN UserCharities friendCharity ON friendCharity.userID = uc.contactID AND friendCharity.relationshipType IN ( 1,3 )...

mpasha replied 3 months, 1 week ago
helo... i have a problem with some tables and getting data from them... hope some one can help me... ok i have two table TABLE A: -id - product_number -costs TABLE B: -id - product_number - typ_of_product the two product_number are the same... now the idea si this: i need to get all the typ_of_product which made in TABLE A most costs ORDERED BY DESC and ...

mpasha replied 3 months, 1 week ago
ok i have solved it thanks anyway: CREATE VIEW temporary AS SELECT `produkt_numer` as numer, `typ_of_product` as typ,`costs` as s FROM `tableA` , `tableB` WHERE `tableA.product_number` = `tableB.produkt_number`; select count(numer) as howmuch, typ from temporary group by typ order by homuch desc;

r937 replied 3 months, 1 week ago
i'm glad you solved it, but i should like to point out that ... 1) `tableA.product_number` and `tableB.produkt_number` are invalid (you can't put backticks around the qualified columns like that) 2) you don't actually need a view Code: SELECT COUNT(*) AS howmuch , typ FROM ( SELECT tableA.product_number AS numer , tableB.typ_of_product AS typ...

 

Top contributing authors

Name
Posts
r937
45
user's latest post:
Problems in my WHERE clause :(
Published (2009-12-09 12:10:00)
first thing you should do is rewrite the query to use JOIN syntax secondly, if you are "querying the DB for a specific client name" then you should put that into the WHERE clause Code: SELECT ... FROM trips INNER JOIN locations ON locations.id = trips.locationid INNER JOIN salesmen ON salesmen.id = trips.salesmen_id WHERE trips.client_name = 'Mr. Jones' the third step is to figure out which columns you want in the...
sakis
16
user's latest post:
duplicate ids not returned
Published (2009-12-07 10:37:00)
Hi i am having a query such as Code: SELECT * FROM #__vm_product AS prd INNER JOIN #__vmfprodsubcategory AS feat ON feat.product_id=prd.product_id INNER JOIN #__vm_product_category_xref AS cat ON cat.product_id=prd.product_id WHERE prd.product_id IN (1,5,5,6) AND cat.category_id=1 GROUP BY prd.product_id As you have seen there is a Code: WHERE prd.product_id IN (1,5,5,6) where some ids are being reffered more than 1 times. But the query...
healdem
14
user's latest post:
mysqlimport
Published (2009-12-11 03:45:00)
nope becuase it'd be virtually impossible to code the import file for this. there is no way I could conceive that you would be bale to make an import process flexible enough to decide off its own bat whcih fields go where if there are fields missing in the input stream if you don't have data for the column then supply a null value, usually this is a comma followed by another comma if you are using CSV
dav1mo
13
user's latest post:
Aggregate of a Aggregate...
Published (2009-12-10 12:55:00)
you would, also, need a count of the days of the week. In your instance here that would be a 2, maybe another subquery and then calculate avg on your own? Dave
Theresonly1
12
user's latest post:
Database inheritance - not sure...
Published (2009-12-06 16:39:00)
Hello I have just designed a database with an inheritance relationship. I have supertype as a table on its own. Each subtype would also have a table too. i need to reference the supertype with the subtype. supertype table: - id (PK) - ..other fields each subtype table: - id (PK) - ..unique sub fields Should i make subtype id a FK as well as a PK so it can reference its parent supertype? OR should i introduce an additional field that does the...
mike_bike_kite
11
user's latest post:
$20 via paypal if you can solve...
Published (2009-12-07 09:28:00)
As a moderator I should point out you can (and should) be getting your answers for free like everyone else but seeing as it's Christmas I'll put your donation towards the kids presents
Bazzaah
9
user's latest post:
Link mySQL db to content - Page...
Published (2009-11-21 09:06:00)
No. Registered users will just use the site to stream content - they won't have the facility to add their own content.
lse123
8
user's latest post:
an html table field...
Published (2009-12-09 18:14:00)
WELL MAY the table field prior be int converted to string... a new problem: When I have a text area and somebody types in without space when appeared data in html table the structure modified to fullfill the long word like typing "ffffffffffffffffffffffffffffffffffggggggggggggggg gggggggggggggggfffffffffffffffffffffffffffffgggggg ggggggggggggggggggggggggfffffffffff" well is any way from textarea text get cut in the middle so...
sstory
7
user's latest post:
MySQL free or not?
Published (2009-11-23 10:30:00)
Thanks for the comments!
gvee
7
user's latest post:
Questions!!!questions!!!question...
Published (2009-12-02 08:58:00)
This sounds like an error in your PHP, not your database. Get any error messages?

Related threads on "dBforums - Database Support Community":

Related threads on other sites:

Thread profile page for "MAX() in WHERE clause" on http://www.dbforums.com. This report page is a snippet summary view from a single thread "MAX() in WHERE clause", located on the Message Board at http://www.dbforums.com. This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity