Okay
  Public Ticket #3766444
not able to create a view with two tables
Open

Comments

  • Stefan started the conversation

    Good morning

    Hopefully you can help me. I think I have a simple table structure.
    I'm creating a sports ranking website. We have athletes and we different activities. We will have 20 SkillChallenges as well as different runs. 
    The athletes will have 3 tries on each SkillChallenges to complete.

    My current table structure

    - one table with the Athletes (id, nr, name, gender, age, cat)
    - one tables for the SkillsChallenges (id, T1, T2, T3)

    At the end I need a view for each SkillChallenge so that we are able to add the points directly on the SkillChallange station.
    We also need some other views but I think once I'm able to get this working then I'm also able to get all other views working.

    Now I created a VIEW where I combine two table, see attached url.
    => https://ninja-scoring.com/test/index.php/elementor-78/

    and here the SQL Statement I used... I tried it as view on the DB as well within the plugin... 

    --CREATE VIEW OG_S1 AS
        SELECT 
    OG_TeilnehmerTest.nr,
        OG_TeilnehmerTest.name, 
    OG_TeilnehmerTest.Gender, 
    OG_TeilnehmerTest.Age,
    OG_TeilnehmerTest.Cat,
    OG46_1.T1,
    OG46_1.T2,
    OG46_1.T3
    FROM OG_TeilnehmerTest, OG46_1
    WHERE OG_TeilnehmerTest.wdt_ID = OG46_1.id

    I also have the plugin Elementor Pro in use and created the website with it. 

    Now I get the following error messages when I try to modify a value on the front-end.
    - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB.
    (But I was able to save it, also the statement works when I run it on the DB itself.)

    Then I thought it would make sense to only allow editing on the T1, T2, T3 which is a table so that not both tables are affected without success... 

    So now I hope you can help me to get this working. 
    I don't want to create full tables, means that every table contains the athlete's name and so on. 

    So we are not able to correct anything during the check-in from the athletes. Because then we have to correct it manually on more then 20 tables... 

    I'm looking forward to hear soon from you. 

    Kind regards,
    Stefan Anderegg


  • Stefan replied

    Did another test right now. 

    Dear Support Team

    On your page I found the tipp to split it to two databases. So I was in contact with my hoster. He created now a second DB and permit the same user to both DB's

    Now I did a test to combine the two tables but I still get the error message during the front-end editing. Here the SQL statement I used.

    CREATE VIEW OG46_test2 AS
    SELECT
    OG46_Teilnehmer.Nr,
    OG46_Teilnehmer.`Name`,
    OG46_Teilnehmer.Gender,
    OG46_Teilnehmer.Age,
    OG46_Teilnehmer.`Cat`,
    OG46_1.T1,
            OG46_1.T2,
            OG46_1.T3
    FROM NinjaScoringUser.OG46_Teilnehmer, OG46_1
    WHERE NinjaScoringUser.OG46_Teilnehmer.id = OG46_1.id


    Then I had a idea to use one table and a view. The table "OG46_Teilnehmer" is nothing I need to edit / modify for this task. So I created the following view 

    CREATE VIEW OG46_test3 AS
    SELECT
    OG_TeilnehmerView.id,
            OG_TeilnehmerView.Nr,
    OG_TeilnehmerView.`Name`,
    OG_TeilnehmerView.Gender,
    OG_TeilnehmerView.Age,
    OG_TeilnehmerView.`Cat`,
    OG46_1.T1,
            OG46_1.T2,
            OG46_1.T3
    FROM NinjaScoringUser.OG_TeilnehmerView, OG46_1
    WHERE NinjaScoringUser.OG_TeilnehmerView.id = OG46_1.id;

    where I point to the view instead of a table. But i got the same result during front end editing... 


    Please help

    Many thanks
    Stefan Anderegg