Jump to content

Search the Community

Showing results for tags 'joins'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 4 results

  1. I have never done any calculations with sql query, so I have no idea how to do this so please help. well i have two tables acc_tbl and ledger_tbl ( screenshots ) i need to find the the difference between total debit and total credit of that particular ledger debit (Dr) and credit(Cr) everything in screenshot. All i know was to join the table and select all thr columns available.
  2. I am trying to generate a report that will assist a client in determining price changes for their products. The query I need to use is bugging the hell out of me. I have extracted a portion of it as the other parts are irrelevant. What I am trying to do is display the number of times a product has been ordered of a certain quantity. I am attempting to concatenate the quantity with the number ordered. i.e. product_model_id model_code qty_orders ---------------------- --------------- ------------- 12 12345 1:32,2:12,3:2 So for the above product (12) the following info is returned A quantity of 1 has been ordered 32 times A quantity of 2 has been ordered 12 times A quantity of 3 has been ordered 2 times I can pull the qty_orders data out without issue by specifying the id of the product, however I need to display for all products including the additional information (product_model_id, model_code). Here is the database structure: product_model ------------- product_model_id model_code order_product ------------- op_id order_id product_model_id quantity I know that I need to do the sub query within a join but I can't get it quite right. Here is the part I have down. I need to get rid of the WHERE product_model_id=12 bit and create a join to product_model so I can display all products. SELECT GROUP_CONCAT(quantity, ':', total_ordered) AS qty_orders FROM ( SELECT quantity, COUNT(op_id) AS total_ordered FROM order_product WHERE product_model_id=12 GROUP BY quantity ) AS sq Complex SQL isn't really my forte so any help would be appreciated.
  3. I have 2 queries that I want to join together to make one row This queries returns all rows from both tables which is what i want SELECT table_A.*, table_B.* FROM table_A INNER JOIN table_B ON table_A.code = table_B.code and this is the output table_A.id | table_A.code | table_B.id | table_B.code | table_B.complete =============================================================================================== 1 | 123456 | 1 | 123456 | yes 2 | 654321 | 2 | 654321 | no and this is the second query SELECT table_C.*, table_D.* FROM table_C INNER JOIN table_D ON table_C.code = table_D.code INNER JOIN table_B ON table_D.code = table_B.code WHERE table_B.complete = 'yes' and again the output table_C.id | table_C.code | table_D.id | table_D.field2 | table_B.complete ======================================================================================== 1 | 123456 | 1 | 123456 | yes What I've been trying to for the last couple of days is join the 2 queries together to make one query that returns this table_A.id | table_A.code | table_B.id | table_B.code | table_B.complete | table_C.id | table_C.code | table_D.id | table_D.field2 | table_B.complete ==================================================================================================================================================================================== 1 | 123456 | 1 | 123456 | yes | 1 | 123456 | 1 | 123456 | yes 2 | 654321 | 2 | 654321 | no All i want it to do is get all rows from tables A and B and return all rows from C and D only if table_B.complete equals "yes". All tables are joined by the code column which all have the same value
  4. Hi! I can't figure out this code: SELECT Student.fornavn,etternavn,brukernavn Fag.fagkode, COUNT(Oppgave.nr) AS AntalOppgaver FROM Student,Fag LEFT JOIN Student WHERE Fag.fagkode='DAT1000' = Syntax error , mariadb....... The task text is : The question should get an overview of all students(Here: Student) in a choosen subject(Here:fag) and count how many tasks(here:oppgave) The overview should show sirname(Etternavn)name(Fornavn) username(Brukernavn)and numbers of tasks in the subject(fag) The overview shuld be order by sirname(etternavn)and then on name(fornavn) Any idea? - Look at the E/R attachment
×
×
  • 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.