Софтуерно Инженерство
Loading...
kosio197 avatar kosio197 104 Точки

Problem 11. Mix of Peak and River Names From Built-in Functions

Привет,

Това ми е заявката, на локалната база изглежда наред, но в judje връща грешен отговор:

SELECT p.peak_name , r.river_name,
 LOWER( CONCAT(SUBSTRING(p.peak_name, 1, LENGTH(p.peak_name)-1), r.river_name))  AS mix
  FROM peaks AS p, rivers AS r
   WHERE (SUBSTRING(p.peak_name,  LENGTH(p.peak_name), LENGTH(p.peak_name)) = SUBSTRING(r.river_name, 1,1))
     ORDER BY mix;

Къде може да ми е грешката?

Тагове:
1
Databases Basics - MySQL
velmona avatar velmona 1 Точки

 

Вариант 1:

SELECT p.peak_name, r.river_name, lower(CONCAT(p.peak_name,substring(r.river_name,2))) as mix
FROM peaks p, rivers r
WHERE SUBSTRING(REVERSE(p.peak_name),1,1)=SUBSTRING(r.river_name,1,1) ORDER BY mix;

Вариант 2:

SELECT peak_name,river_name, LOWER(CONCAT(peak_name,SUBSTRING(river_name,2)))  AS mix
FROM peaks p, rivers r
WHERE RIGHT (p.peak_name,1)=LEFT(r.river_name,1)
ORDER BY mix;

0