需要帮助正确获取SQL字符串/查询

时间:2021-10-18 01:56:48

Here is a snippet of code which most likely clears what I want to achieve, but is written badly, especially the final string/query. Basically I make links based on these strings/query.

下面是一段代码,它很可能会清除我想要实现的内容,但编写得很糟糕,特别是最终的字符串/查询。基本上我根据这些字符串/查询建立链接。

$theanimeid = $row1['anime_id'];
$theanimetype = SELECT * FROM animelist WHERE id=".$theanimeid.";
$echothetype = if $theanimetype['type']=1 echo Movie else echo Episode;

The link:

$link="Stream-".$title."-".$echothetype."-".$row1['episodes_id']."-".$row1['language']."-".$row1['id'];

Some clearing up: $row1 is getting data from the table 'videos', but the column 'type' is inside 'categories' therefore first we need to match the anime_id, a column with the same value as the column id of categories to locate the correct data (I think).

一些清理:$ row1从表'videos'获取数据,但列'type'在'categories'内,因此首先我们需要匹配anime_id,一个与要定位的类别的列id具有相同值的列正确的数据(我认为)。

After that we need to get the value for column 'type' in that same row, which is either 0 or 1.

之后,我们需要在同一行中获取列'type'的值,该值为0或1。

If you need extra information I will reply on the spot, as I refresh this page every minute to see if someone answered, I really need help and it is appreciated.

如果您需要额外的信息,我会当场回复,因为我每分钟刷新一页,看看有人回答,我真的需要帮助,我很感激。

Thanks in advance, Inder

提前谢谢,Inder

1 个解决方案

#1


0  

Do You mean something like that:

你的意思是这样的:

$thetype = $theanimetype['type'] == 1 ? 'Movie' : 'Episode';

???

Or maybe doing this in the SQL query:

或者也许在SQL查询中执行此操作:

SELECT *, 
    CASE type
        WHEN 1 THEN 'Movie'
        WHEN 0 THEN 'Episode'
    END AS animeType
FROM myTable

#1


0  

Do You mean something like that:

你的意思是这样的:

$thetype = $theanimetype['type'] == 1 ? 'Movie' : 'Episode';

???

Or maybe doing this in the SQL query:

或者也许在SQL查询中执行此操作:

SELECT *, 
    CASE type
        WHEN 1 THEN 'Movie'
        WHEN 0 THEN 'Episode'
    END AS animeType
FROM myTable