Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6098993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:13:19+00:00 2026-05-23T13:13:19+00:00

I have this SQL and it goes like it was thought, but I guess

  • 0

I have this SQL and it goes like it was thought, but I guess there is a better way to write it in order to avoid repetitive sentences and increase the performance.

Any suggestions?

CREATE OR REPLACE VIEW tx_oriconvocatorias_consultas AS
SELECT pubs.*, pais.nombre_es as area,
GROUP_CONCAT(DISTINCT linea_es ORDER BY linea_es SEPARATOR '\n') as linea_es,
GROUP_CONCAT(DISTINCT modalidad_es ORDER BY modalidad_es SEPARATOR '\n') as modalidad_es,
GROUP_CONCAT(DISTINCT orgs.nombre_es ORDER BY orgs.nombre_es SEPARATOR '\n') as organizacion_es
FROM tx_oriconvocatorias_publicadas AS pubs

INNER JOIN tx_oriconvocatorias_publicadas_lineas_mm as ml
ON ml.uid_local=pubs.uid

INNER JOIN tx_oritablascomunes_lineas as lins
ON ml.uid_foreign=lins.uid

INNER JOIN tx_oriconvocatorias_publicadas_modalidades_mm as mm
ON mm.uid_local=pubs.uid

INNER JOIN tx_oritablascomunes_modalidades as mods
ON mm.uid_foreign=mods.uid

INNER JOIN tx_oriconvocatorias_publicadas_organizaciones_mm as mo
ON mo.uid_local=pubs.uid

INNER JOIN tx_oritablascomunes_organizaciones as orgs
ON mo.uid_foreign=orgs.uid

INNER JOIN tx_oritablascomunes_paises AS pais
ON pubs.carea = CONCAT('tx_oritablascomunes_paises_',pais.uid)
GROUP BY uid

UNION

SELECT pubs.*, regs.nombre_es as area,
GROUP_CONCAT(DISTINCT linea_es ORDER BY linea_es SEPARATOR '\n') as linea_es,
GROUP_CONCAT(DISTINCT modalidad_es ORDER BY modalidad_es SEPARATOR '\n') as modalidad_es,
GROUP_CONCAT(DISTINCT orgs.nombre_es ORDER BY orgs.nombre_es SEPARATOR '\n') as organizacion_es

FROM tx_oriconvocatorias_publicadas AS pubs

INNER JOIN tx_oriconvocatorias_publicadas_lineas_mm as ml
ON ml.uid_local=pubs.uid

INNER JOIN tx_oritablascomunes_lineas as lins
ON ml.uid_foreign=lins.uid

INNER JOIN tx_oriconvocatorias_publicadas_modalidades_mm as mm
ON mm.uid_local=pubs.uid

INNER JOIN tx_oritablascomunes_modalidades as mods
ON mm.uid_foreign=mods.uid

INNER JOIN tx_oriconvocatorias_publicadas_organizaciones_mm as mo
ON mo.uid_local=pubs.uid

INNER JOIN tx_oritablascomunes_organizaciones as orgs
ON mo.uid_foreign=orgs.uid

INNER JOIN tx_oritablascomunes_regiones AS regs
ON pubs.carea = CONCAT('tx_oritablascomunes_regiones_',regs.uid)
GROUP BY uid
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:13:19+00:00Added an answer on May 23, 2026 at 1:13 pm

    Yes. Use a view to collect up all the sql common to both queries:

    CREATE VIEW PUB_ORGS AS
    SELECT *
    FROM tx_oriconvocatorias_publicadas AS pubs
    INNER JOIN tx_oriconvocatorias_publicadas_lineas_mm as ml ON ml.uid_local=pubs.uid
    INNER JOIN tx_oritablascomunes_lineas as lins ON ml.uid_foreign=lins.uid
    INNER JOIN tx_oriconvocatorias_publicadas_modalidades_mm as mm ON mm.uid_local=pubs.uid
    INNER JOIN tx_oritablascomunes_modalidades as mods ON mm.uid_foreign=mods.uid
    INNER JOIN tx_oriconvocatorias_publicadas_organizaciones_mm as mo ON mo.uid_local=pubs.uid
    INNER JOIN tx_oritablascomunes_organizaciones as orgs ON mo.uid_foreign=orgs.uid;
    

    then build your unioned queries from this

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is sort of SQL newbie question, I think, but here goes. I have
This question might be kind of elementary, but here goes: I have a SQL
I have a SQL query that goes like this: UPDATE User SET flag='Y' WHERE
I have a simple sql query that goes like this: SELECT * FROM leaderboard
I have an SQL query that goes like this: $stmt = $dbh->prepare(INSERT INTO Places
I have a script in T-SQL that goes like this: create table TableName (...)
I have a sql exception from clojure that goes like this: java.lang.Exception: transaction rolled
This is probably a naughty use for sql... But here it goes.... I have
I have this sql: ALTER TABLE dbo.ChannelPlayerSkins DROP CONSTRAINT FK_ChannelPlayerSkins_Channels but apparently, on some
I have a stored procedure that goes something like this (pseudo code) storedprocedure param1,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.