dor2p0520 2012-09-11 18:41
浏览 37

如何计算具有特定行名称的填充行 - 我的sql

What I want to do is count all my filled rows of specific row name I select, let me give you an example:

Its like I have a table with 6 columns; the very first column is email - and the rest column are slot1, slot2, slot3, slot4, slot5.

Now what I want to have is a function that - when I select a specific email address - it returns how many slots are filled under that email address - just like when we use this command:

$t = select * from tabnlename where email=something 
mysql_fetch_array($t)
echo $t['slot1'] . $t['slot1'] and on and on ...

I want a function that counts how many slots are filled where email = mychoiceemail.

Let me give you some more details take a look at my sql table

supemail           slot1          slot2         slot3           slot4         slot5
opera@gmail.com   somedata       somedata       somedata        somedata       somedata
kaku@gmail.com     somedata                    somedata         somedata
nashu@gmail.com                  somedata

now what i want is when i select opera@gmail.com the function should return 5 as it has all 5 columns filled ! when i select kaku@gmail.com it should return 3 as it has 3 slots filled and when i select nashu@gmail.com it should return 1 only as it has only 1 slot filled !

  • 写回答

3条回答 默认 最新

  • duanbangzhou7809 2012-09-11 18:47
    关注

    Have a look at mysqli_query, there are plenty of examples there.

    Your query could look something like:

    select Count(*)
    from MyTable
    where email = $something
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥15 帮我写一个c++工程