Jump to content


  • Posts

  • Joined

  • Last visited

684425's Achievements

Regular Member

Regular Member (3/5)



  1. Thank you sir for guiding me. The result i want from query is like... +---------+-----------+----------+ | user_id | status_id | username | +---------+-----------+----------+ | 14 | 1 | user14 | | 13 | 1 | user13 | | 8 | 1 | user8 | | 7 | 1 | user7 | | 6 | 1 | user6 | | 12 | 2 | user12 | | 11 | 2 | user11 | +---------+-----------+----------+ I had to modify my table. added more columns now. so i need to get values in separate columns instead of rows
  2. Thanks for guiding sir. I have one problem that my script is divided in multiple files. i will have to check if i can apply it there.
  3. I am trying to get rows from MYSQL table (attachment) based on: Select last five rows where status_id = 1 Select last two rows where status_id = 2 *I did use UNION with two SELECT queries to get whole data as one array. Now on PHP side... I have first block for rows having status_id 1 so if there are rows having status_id 1 then PHP should display the data otherwise if there is no row having status_id 1 then PHP should print NO DATA only once. I have second block for rows having status_id 2 so if there are rows having status_id 2 then PHP should display the data otherwise if there is no row having status_id 2 then PHP should print NO DATA only once. I did use foreach loop then within loop i did use if condition to check status_id of rows. it works fine when i omit NO DATA part but when i add it. the result shows both rows and NO DATA in first block when there are one or more rows having status_id 1 but no row having status_id 2 Which made me believe that i was doing it the wrong way. Please guide me *PS: I know its PHP section the thread should be related to PHP problem but... is it right to use UNION in query? or should i post a new thread in relevant section for guidance?
  4. Is there any function in php lib that does the following $a = 1238; $n = 48; // 1*2*3*8 or I will have to create one for my script? (I want to do it for both client and server sides based on request sent by user. I actually want it in php that is why i asked it here, but if the solution (as function) is available in javascript (not jQuery) please share or guide me.)
  5. I was trying it with a subquery and got confused. Thank you 🙂
  6. I have a column (unix_values) in table where multiple values are stored in unix timestamp which i want to convert into date yyyy-mm-dd and copy to another column (date_values) using single query Any help please?
  7. Agree with you sir but the problem here is that DB is already created and filled with data. I tried to move data to a new DB and i was discussing the matter here. In the middle i was stopped from doing this, so i have to continue with the old one. Here in my first post i pasted a sample of only those fields on which i wanted to run queries like as query total amounts paid by each customer, find number of customers whose total payments are (1. less than given input, 2. equal to given input, 3. greater than given input) What i am facing here is, old DB is not normalized, also (dynamic?) values calculated from other values are stored in tables (the exact term for calculated is slipped from my mind) The image in this reply is corrected one (in my opinion, not in the DB i am working on) Here invoices.id is primary key in invoices table and installments.invoiceid id foreign key in installments table. i created these two tables (invoices and installments) and inserted exactly same data, then ran the following query and it worked. I just wanted to confirm that, is this query correct for any situation limited to these two tables? or is there something that i missed? SELECT invoices.invoice, invoices.downpay, SUM(installments.payments) AS paid FROM invoices LEFT JOIN installments ON invoices.id = installments.invoiceid GROUP BY invoices.id I also want to apologize. I am very sorry for creating this mess and confusing all of you. I hope that i will be forgiven by all the contributors who tried to help me here.
  8. 1. You are right sir. this column should be named as customerid but it is named as invoice and i am not allowed to change it. 2. There is only one duplicate in history data but that account is closed. After that every customer is assigned a unique invoice.
  9. Sir, i have reached at this SELECT customers.invoice, customers.downpay, SUM(installments.payments) AS paid FROM customers LEFT JOIN installments ON customers.id = installments.invoices GROUP BY customers.id Please guide me if i am wrong
  10. Sorry sir, it is... TableA is customers (id, invoice, downpay) TableB is installments (id, invoices, payments) TableC is the result of query that i want to run on both customers and installments Sir i am not allowed to modify DB structure and i do not want to do that because it already is filled with lots of records. I can run only queries on data.
  11. In another query i will need to repeat the same and then also i will have to count records from result where BBB + CCC = 10000. Please guide me🙂
  12. I have two tables as shown in image, I want to join sum of records from table B based on keys in both tables to get the desired result as mentioned in third table. Please guide🙂
  13. I have added an image, User requirements are: Vendors, items by vendors and payments to vendors How many vendors are there? Which vendor has sold him what on which date (and what is the status of registration, file, copy and plates)? How much amount (each transaction by date) has been paid to a specific vendor and what is the current balance? Clients, items by invoice number and payments collection from clients Which client has bought of which vendor's item on which date? Who handled the client, filled the form and received advance from client? (There are three persons, user, his father, his brother. Form filling and advance receiving must be done by the same person) Which client has paid all the amount? (in full or in parts) the status must be shown as cleared for this category Which client is still paying installments? (is he/she paying on time or not? if yes then status shown as pending else defaulter) If a mistake by one of those who handle clients, is found then status should be as error Daily, weekly, monthly, yearly etc summary of collected payments can be generated (I may have missed something, i will add it later. Also i will try to complete database structure and upload soon IA)
  14. No sir, A are the companies (always sellers), C are individuals (always buyers) Agree sir, I am confused in both database structure and frontend, so i added this. But it is not added now. Currently i am working on Excel, i will post screenshots tonight in next reply IA.
  15. Sir, this is only for bikes. I am sorry i forgot to mention it in my post.
  • 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.