PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, February 18, 2022

[FIXED] How to display the information of the customer who has the most 'use' in 'audit' table (Stored Procedure)

 February 18, 2022     phpmyadmin, sql, stored-procedures     No comments   

Issue

How to display the information of the customer who has the most 'use' in 'audit' table.

problem i dont know how to get information customer.

  select * from audit where used=
(select MAX(used) from audit)

audit table

enter image description here

customer table

enter image description here


Solution

Sort your subquery highest to lowest and then take the first row with LIMIT 1.


Select *
FROM customer_table
WHERE customer_ID = (
                     SELECT customer_ID
                     FROM audit_table
                     ORDER BY USED DESC
                     LIMIT 1
                     )

You may want to consider what happens if two customers have the same value in USED. It looks like there is a tie between C001 & C002 but this query will only return one customer



Answered By - urdearboy
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

1,205,455

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © 2025 PHPFixing